Not Enough Parenthesis

Posted on Sat 11 March 2017 in misc

Lisp Heart I

I might be becoming a lisp weanie. I never thought that parenthesis would be my be-all-end-all. But I like them. I'm taking some sips from the functional cool-aid.

How did this happen? I'm always into learning more about programming. The two languages I've been most into have been Python and Javascript, which are very similar languages. Not much of a way to grow as a programmer. So what are some languages to branch out into? A good way to start is to consider the weaknesses of Python, "the language I think in":

  • Performance
  • Concurrency

There is also the prevailing wisdom that learning programming in the functional style will make you a better programmer even in other languages. After a brief foray into Rust, which was massively performant but also came with many low level systems considerations on top of everything else (another time!), I settled on Clojure.

Clojure and Python are of a kind.

Two sources had a great impact on my decision. The first was a great article on Clojure from the perspective of Python: Clojonic: Pythonic Clojure

This article begins by noting one of the more important features of the language, its creator Rich Hickey:

In stark contrast to Guido van Rossum in the Python community, Rich Hickey is undeniably not just the Clojure language’s creator, but also a kind of spokesperson for a functional programming renaissance. Guido van Rossum generally lays low and lets the Python language and community speak for itself, and tries to avoid controversy. To him, Python is just a popular tool he happened to create, and it doesn’t represent any major paradigm shift in programming. It’s a positive evolutionary improvement supported by a great open source ecosystem and community. To Hickey, however, “traditional” programming languages — but especially popular ones with an object-oriented focus, such as Java and C++ — are just plain wrong. He proposes Clojure as an antidote of sorts.

His talks are fantastic and should be watched multiple times, even if Clojure is not your main language. I recommend checking out Rich Hickey's Greatest Hits for a selection of his best talks.

The Pixel Monkey article continues to talk about some of the most important points of emphasis of Clojure (Immutability/Composability/Scalability/Productivity) and finishes with implementing similar things in Python and Clojure, finding more similarities than expected. It even makes it a point to introduce threading, which is a nice way to make code more readable. For example, the leading image, while demonstrating in my mind some of lisp's charm, can seem 'backwards' for people to read. With threading, however, it can be written as:

Threaded I Heart Lisp

In a different reality, I could have called Rust friend.

The other main influence to me was a comment on, oddly enough, the Rust subreddit: Would learning Rust & Rust concepts help a developer who works mostly on web development and sometimes neural networks? (say more than Clojure would?)

Addressing someone in a similar situation as me and considering the same two languages, the commenter (grayrest) outlines the benefits of both in a clear way before recommending Clojure.

Both are worth learning. If I were going to pick one, I'd pick Clojure. My primary lens for understanding and designing systems is thinking about the shape and flow of state through the system. I think state is the core of incidental complexity in programming and thinking deeply about it is the second most important thing in designing systems (the first is picking abstractions, which is the core of inherent complexity). I came to my understanding of state through Clojure and its community. There are probably other ways to learn it but this is the path I know about.

Even though I wound up choosing Clojure, the way the commenter talks about the benefits of Rust makes me want to circle back to that as well. Someday I'll get more into types, low-level systems programming and bleeding edge performance. Those concepts are just not germane to my needs right now.

More parallels

Evil Clojure From a Parallel Universe

It also turns out that Clojure has may parallels to React, something else that I've gotten into recently. React's functional approach to rendering HTML fits incredibly well with Clojure and so Clojure was an early adopter (see this mention of ClojureScript on the React blog in 2013) and shared ideas (React performance page recommends Clojure-like immutable data structures, Facebook's Immutable-js library mentions Clojure 3 times and has a Rich Hickey quote). Redux may be one of the most popular state management libraries for React and it is highly functional. ClojureScript, in addition to being a very mature transpile-to-JS technology, also has om.next, its answer to the next Facebook's GraphQL and Netflix's Falcor for performing API data calls that are more complex than REST.

I don't yet know how much I'll use ClojureScript. I did modify Krypto to use Redux for state management under the hood but I ran up against quite a learning curve when trying to re-implement Krypto in om.next. Krypto is probably far too simple to see benefits from the more complex state management libraries anyways.

Meanwhile, I've been through Clojure for the Brave and True, been working my way through the exercises in 4Clojure, and I've even started reading Clojure Applied. Even more, I've gotten into Spacemacs, an Emacs variant, due to its utility for writing Clojure and lisps in general. It's far from my main editor but I've been dipping my toes in org-mode and slowly been going further into the rabbit hole.

We'll see how it all goes. I like the parenthesis and I'm finding that the code I write comes out elegant by default, more so than in other languages. The most important thing is that I'm growing as a programmer and continuing to work on things that excite me and to boldly go to new frontiers of programming!


Continue reading

New version of Krypto... in React!

Posted on Sun 06 November 2016 in misc

Recently I've been catching up on my web technologies. I've always liked the way you can put together universal and programmatic documents with HTML and web applications. I remember turning my nose up to Django and contributing to Turbogears (if anyone remembers that) back in the day. I've also used JQuery several times to make my own little dynamic web pages and widgets. These were all one-off, not often re-used and I felt very cool about them. It looks like web technology has gone through a sea change, though, and I wanted to keep up. I often make little dashboards and have been increasingly using web pages as a universal GUI and with things like Project Electron that seemed to apply more than ever.

My learning path:

  • Eloquent Javascript: I got this through a humble book bundle but you can also read it for free online. I did not to all, or even many, of the exercises but it was instrumental in taking Javascript from an unfamiliar language that I was fighting to a genuinely useful tool.
  • React.js Introduction For People Who Know Just Enough jQuery To Get By: A nice, not too heavy, introduction as to the place of React and similar frameworks. React seems complex and jQuery is easy to understand and get things done with very quickly but this article does a good job in both introducing React and the need for React. It also lead me to the next step below:
  • Wes Bos's React for Beginners: A nice, focused course on building a React Web Application. It is an objectively crazy pace. Much of it feels like a whirlwind tour and there are depths of things that are skipped or glossed over completely and many times I stopped to ask the question: "Whaaaaa?" But there is right now a great background of web technologies that it would be foolish to try and cover everything. The is necessarily focused on React and it does that well. Very time efficient too, as I was able to get through it in a few afternoons.
  • Learn HTML/CSS by Shay Howe: I've always used Bootstrap for just about everything I've done and it has always seemed a bit magic. For my next project I decided to do the CSS on my own. Also it was a nice opportunity to get introduced to those newfangled HTML5 tags.

The result of all the above is a new version of the Krypto Game. The previous version (still available here) was a bit of a mess, with spaghetti Javascript code, jQuery because I didn't know different and Bootstrap for CSS. This one uses React and my own CSS (apart from resets and gradient generators).

They are about the same size, surprisingly. Actually the old version, that includes all of jQuery and Bootstrap and my unminified code would probably be smaller if I minified my code. A little over 50% of the new version is due to webfonts. I don't regret it, though, they had the single greatest effect in making it look better.

Look forward to using modern web technologies more!


Continue reading

Some Fall Cleaning

Posted on Wed 14 September 2016 in misc

It's been awhile and I've been busy, if not necessarily on this blog. A quick rundown:

Projects

  • Simulation Notebook: You can see the video from my portfolio. This is something that is tremendously exciting to me but I am having trouble finding the time to develop it further or even market it. It's been a busy year!
  • Krypto: Recently I've been brushing up on my Javascript (see the Books section) so I can be more confident in presenting dynamic content on the web. This is the first project that I've used some of the object oriented features of the language. The code is a bit disorganized but it was some good practice in building something new in a somewhat lesser known language for me. I hope to be more confident building interactivity into some webpages with what I've learned (see Bokeh section below).
  • Kaggle: There is a Kaggle dataset that has taken my fancy of late: The SEPTA On Time Performance Dataset. Right now I have a very basic kernel and a forum post in which I confuse days for hours but more is coming!

Books

I'm a bit weird in that I like reading not just books but programming books for fun. A few notables from my plate:

  • Fluent Python: Excellent book, just excellent. I know Python and have been working with it for some number of years. This book, however, opened my eyes to some of the inner workings and underlying design decisions that make Python such a pleasure to work with. Areas of the language that seemed obtuse to me before were presented with opinionated context and through the gradual buildup I understood concepts that I previously found confusing. Also, more importantly, I got valuable context on when 'not' to use advanced features, avoiding the "Everything looks like a nail" situation. Great intermediate Python book.
  • Algorithms to Live By: Self-help with programming? Such an odd but delightful concept but it makes sense that we can apply all of the research done in computer algorithms to our day to day lives. The best organization system is a pile (LRU Cache). You can vastly improve your predictions of the future by first selecting one of three probability distributions. Being in a rut in life is just a local minima that can be overcome with an injection of randomness. I cannot overstate how much I liked this book.
  • Eloquent Javascript: I got this in the humble programming bundle. Great supposedly introductory book that quickly ramps up in difficulty. I will go back and review certain of the chapters but I highly enjoyed it.
  • Sublime Text Power User: I've had the paid version of SublimeText for some time now but I've never really put it through it's paces. I hope to fully come up to speed with this book + video lectures.

Links

  • Modern Pandas: Goes beyond the basics and presents how to use Pandas in a thoughtful, pandorable way. A nice intermediate tutorial
  • Brandon Rhodes Tutorials: An excellent lecturer, clear explanations and good presentations. I found the Pandas and SQL tutorials quite nice for brushing up and becoming cleaner with tools that I already know.
  • Bokeh: I find the architecture of this young project fascinating and powerful. Really looking forward to getting into it more. At my work, where programming is not a major focus, the static but interactive html documents it produces have been killer for me. I used to think that you needed a backend server to have most types of widgets/interactivity but it looks like you can also accomplish this by using more Javascript. A major motivator in my learning of Javascript more deeply.
  • Linear Regression With Python: Nothing too earth shattering here but I highly appreciated the explanation of those other terms from a regression analysis in statsmodels :)

Continue reading

A Timeline of Solar Exploration - Moved!

Posted on Sun 19 June 2016 in misc

Looking for an interactive visualization? Here you go!

Solar Visualization Thumbnail

This Github Pages site was originally created just to host my Solar Exploration Timeline visualization done in D3 for my Udacity Nanodegree. I couldn't put it on bl.ocks.org because of the Bootstrap formatting that I used.

Now that I made this site a thing, you can find our previously featured visualization here. Enjoy clicking and zooming around the solar system!


Continue reading