It was during the second age
that the great founder of our order Branden Iech,
first stumbled upon the arcane REPL,
and learnt how to bend the fabric of existence to his very will,
then was that he discovered
there was a mechanism to alter the threads
being weaven into the Pattern,
We, programmers, sadly do not live in such a world. But we do have a measure of magic 1 in us, we have the skills and power to create things out of nothingness. And even if we cannot throw fireballs or levitate (yet), we can definitely change/improve/enhance reality and the universe around us with our little creations. Ain’t that freaking awesome?
A Story About Why I Wrote This Book
I was sitting at the back of the room, with my back straight and fidgetting with my fingers on the table. I was both excited and nervous. It was the first time I had ventured myself to attend to one of the unfrequent meetings of my local .NET user group. Excited because it was beyond awesome to be in the presence of so many like-minded individuals, people who loved to code like me, people who were so passionate about software development that were willing to sacrifice their free time to meet and talk about programming. Nervous because, of course, I did not want to look nor sound stupid in such a distinguished group of people.
But don’t just take my word for it. This is what the book is for, to show you.
What is the Goal of This Book?
Writing code is one of my favorite past times and so is reading fantasy books. For this project I wanted to mix these two passions of mine and try to make something awesome out of it.
In fantasy we usually have the idea of magic, usually very powerful, very obscure and only at the reach of a few dedicated individuals. There’s also different schools or types of magic: pyromancy deals with fire magic, allomancy relates to magic triggered by metals, necromancy is all about death magic, raising armies of skeletons and zombies, immortality, etc.
I thought that drawing a parallel between magic and what we programmers do daily would be perfect. Because it is obscure to the untrained mind and requires a lot of work and study to get into, and because we have the power to create things out of nothing.
Is This Book For You?
I have written this book for you C# developer:
How is The Book Organized?
In regards to the size and length of each chapter, aside from the introduction, I have kept every chapter small. The idea being that you can learn little by little, acquire a bit of knowledge that you can apply in your daily work, and get a feel of progress and completion from the very start.
Understanding the Code Samples in This Book
How to Run the Code Samples in This Book
F12 for Chrome if you are running windows or
Opt-CMD-J in a Mac) or with prototyping tools like JsBin, jsFiddle, CodePen or Plunker. Any of these tools is excellent so you can pick your favorite.
For testing ECMAScript 6 examples I recommend JsBin, jsFiddle or the Babel REPL at https://babeljs.io/repl/. Alternatively there’s a very interesting Chrome plugin that you can use to run both ES5 and ES6 examples called ScratchJS.
A Note About Conventions Used in the Code Samples
The book has three types of code samples. Whenever you see a extract of code like the one below, where statements are preceded by a
>, I expect you to type the examples in a REPL.
The code after
> is what you need to type and the expression displayed right afterwards is the expected result:
Some expressions that you often write in a REPL like a variable or a function declaration evaluate to
Since I find that this just adds unnecessary noise to the examples I’ll omit these
undefined values and I’ll just write the meaningful result. For instance:
When I have a multiline statement, I will omit the
> so you can more easily copy and paste it in a REPL or prototyping tool (jsBin, CodePen, etc). That way you won’t need to remove the unnecessary
> before running the sample:
I expect the examples within a chapter to be run together, so sometimes examples may reference variables from previous examples within the same section. I will attempt to show smallish bits of code at a time for the sake of simplicity.
For more advanced examples the code will look like a program, there will be no
> to be found and I’ll add a filename for reference. You can either type the content of the files in your favorite editor or download the source directly from GitHub.
A Note About the Exercises
In order to encourage you to experiment with the different things that you will learn in each chapter I wrap every single one of them with exercises.
It is important that you understand that there is almost no wrong solution. I invite you to let your imagination free and try to experiment and be playful with your new found knowledge to your heart’s content. I do offer a solution for each exercise but more as a guidance and example that as the one right solution.
In many of the exercises you’ll see the following pattern:
This is completely equivalent to:
I just use a helper function
weaves to make it look like Moolen, the mighty wizard is casting a spell (in this case
A Note About ECMAScript 5 and ECMAScript 6,7 within The Book
How will this translate into the examples within the book? - you may be wondering. Well I’ll start in the beginning of the book writing ES5 style code, and slowly but surely, as I go showing you ES6 features, we will transform our ES5 code into ES6. By the end of the book, you yourself will have experienced the journey and have mastered both ES5 and ES6.
Additionally, it is going to take some time for us to start using ES6 to the fullest, and there’s surely a ton of web applications that will never be updated to using ES6 features so it will be definitely helpful to know ES5.
A Note About the Use of Generalizations in This Book
Some times in the course of the book I will make generalizations for the sake of simplicity and to provide a better and more continuous learning experience. I will make statements such as:
If you are experienced in C# you may frown at this, cringe, raise your fist to the sky and shout: Why!? oh Why would he say such a thing!? Does he not know C#!?. But bear with me. I will write the above not unaware of the fact that C# has the
dynamic keyword and the
Do You Have Any Feedback? Found Any Error?
If you have any feedback or have found some error in this book that you would like to report, then don’t hesitate to drop me an email at [email protected].
A Final Word From the Author
There is a hidden goal as well, that is to make it as fun and enjoyable as possible. Therefore the fantasy theme of the whole book, the conversational style, the jokes and the weird sense of humor. Anyways, I have put my heart and soul into this book and hope you really enjoy it!
“Any sufficiently advanced technology is indistinguishable from magic.” Arthur C. Clarke. Love that quote :) ↩