JavaScript: The Good Parts Book Review

If you are new to JavaScript, then you have voluminous options available to your for your pursuit of knowledge. In my case, I started with the ECMA-262 standard for ECMAScript 5. You can tell that there was a lot of love there; though it wasn’t really the right place (at least for me) to get started. Instead I wanted a “when the tires hit the pavement” overview, and the book delivered that.

The book is lovingly written in a way that all technical people should behave, or for that matter, every conscious entity should behave: focus on the positive, respect the negative, and move on with life. The book covers tons of great guts of the language and how to use it “for real”. I need not say more, the book delivers on its promises, and that is why I gave it a 5/5.

The Kindle version looks great, everything is readable. The chapters and sections are light and terse, you get a lot of bang for your buck. In terms of the voice, it wasn’t my personal preference, and for me it was really hard reading, but that is my problem, not the author’s, and consequently the rating stands.

Mastering Web Application Development with AngularJS Book Review

My journey to using AngularJS (NG) was quite raw, relying entirely on the online
documentation, API documentation, blog posts, Google group, and stackoverflow
links. Surely, not unique, but definitely lacking in some ways since the NG
documentation is notoriously brief when you get to the “rich” (aka hard) parts.
After 6 months hacking on NG apps, I got really curious about what “the experts”
had to say and this book seemed to fit the bill.
The first thing that struck me is that the book is not meant to be your first
introduction to web application development of any kind SPA or not. All dev
topics are given some coverage, but it is pretty clear that the authors are
master NG users, so be aware before purchasing it. Topics about how to utilize
NG functionality, debug performance issues, and also optimize them reveal a
solid and in-depth understanding. Although they are at the learning-arc where
they grok it, they are still on that path, and the result is copious amounts of
code in some areas in an attempt to “make the point”, when teaching the point
would have saved a lot of time and space. At times there is a lot of fluff
and over-speak, seemingly meant to blow up the page count, and I blame the
editors for that.
There are many lovable things about this book but I’ll focus on the top two.
First, the book covers real world issues. The build process, authentication,
authorization, build and deploy, artifact management, dependency management,
project structure, and testing are covered in depth. If you want to maintain
your sanity, this book is priceless for the topic alone (experienced developers
will already know all this, but listing the best of breed tools is still
helpful). Second, the authors have a passion for the technology, and that comes
through as they get into relatively under-taught topics like the engine that
powers NG and what you need to know to keep your apps performant. That is
really one of the most interesting things that this book reveals: NG makes
simple apps easy and impossible apps possible, but with a price, you must grok
the engine. Dev teams that laze-out and “wait until we need to” learn how the
guts work will suffer accordingly due to the non-obvious interdependencies of
the event structure inherent to the technology. Their explanation of
transclusion warrants purchasing the book, seriously, no one else seems to truly
understand how to explain the feature (or I’m too dumb to grok the API docs).
The formatting on the Kindle is super. The book is oddly overly simplistic
offering poor coding styles in some parts and extremely amazingly over technical
in others. The coverage on forms is better than everything else out there, and
yet at the same time doesn’t seem to cover reusability of validation and data
models across the enterprise. The chapters on directives are quite nice, and
helps you to “think different” about what it means to serve your client, and
your team using the tech. Pages and pages of code samples could be summarized
with eloquent teaching, but everybody has deadlines so I get it.
_Mastering Web Application Development with AngularJS_ is a delightful book. It
tackles what you will eventually learn on your own. It is kind of like being
able to sit with a NG master and brainstorm with them and listen to their war
stories turned lessons. It is for developers who have been around the block a
few times though, so start elsewhere to learn HTTP, CSS, JavaScript, Async
programming, multi-threaded programming GUI programming, and architecture before
diving into this book. If you grok a functional programming language like
Scheme, and a declarative programming language like CLIPS, then you will
appreciate the amazing and awesome power of AngularJS even more. Thanks for the
great book. 5/5

One Emacs SML Workflow

Being partial to the full-REPL-reboot style of development (ala DrRacket) for most situations I wanted the same thing in Emacs with sml-mode. The value add is that you know all of your files are saved and that your environment is in a fresh and known state. I came up with this:

(defun gcr/sml-eval-buffer ()
  "Intelligently evaluate a SML buffer."
  (interactive)
  (gcr/save-all-file-buffers)
  (let ((sml-process (get-process "sml")))
    (when sml-process
      (quit-process sml-process)))
  (sleep-for 0.25)
  (let ((sml-buffer (get-buffer "*sml*")))
    (when sml-buffer
      (kill-buffer sml-buffer)))
  (sml-prog-proc-load-file buffer-file-name t))

Only to be delighted (though not surprised) to find yet another nearly identical approach here by wenjun.yan:

(defun isml ()
  "If sml repl exists, then restart it else create a new repl"
  (interactive)
  (when (get-buffer "*sml*")
    (with-current-buffer "*sml*"
      (when (process-live-p "sml")
        (comint-send-eof)))
    (sleep-for 0.2))
  (sml-run "sml" ""))

My urge to attain Emacs Comint mastery only grows.

Deleting trailing whitespace for auto savers

real-auto-save is a great package if you like that sort of thing. For example, I like every file to always be saved without me worrying about doing it myself, so I stick with the default save occurring every 10 seconds. A really nice function to call on write-file-hooks is delete-trailing-whitespace, but, with 10s saves this means that in the middle of typing you have spaces eaten and this is clearly unacceptable!
Here is an attempt at a tweaked cleanup function that cleans up every line in the file but for the current line on which your cursor sits:

(defun gcr/delete-trailing-whitespace ()
  "Apply delete-trailing-whitespace to everything but the current line."
  (interactive)
  (let ((first-part-start (point-min))
        (first-part-end (point-at-bol))
        (second-part-start (point-at-eol))
        (second-part-end (point-max)))
    (delete-trailing-whitespace first-part-start first-part-end)
    (delete-trailing-whitespace second-part-start second-part-end)))

Cask for the truly impatient

Thanks to some kind Emacsers I’m now in the modern age using Cask, and what ease it brings to using Emacs. It is truly a joy; anyone not using Emacs for fear of difficulty pulling in packages can let go of their hesitation. It is as easy as writing one config file, installing the packages, and adding a couple lines to your Emacs init script. Here are the basic steps:

  • Clone the cask repo.
  • Add the bin dir to your path.
  • Create a file named Cask, add it to your VCS, and create a link to it from your .emacs.d directory
  • Add a repo and packages to the file.
  • From your .emacs.d directory, run ‘cask’
  • Add the cask load and init to your init file.
  • Start Emacs.

Excellent work by that team.