Hey y'all, it's been a minute.
I was off completing my computer science B.S. (which, is a load of BS but that's another story). The positive was that I had the opportunity to pick my tech stack for once (fuck yeah!) during my capstone class (they ported doctoral/masters thesis to undergrad, fuck yeah!), and I decided I wanted to do something new to me: NodeJS. As someone with experience with other backend shit like Django, Laravel, Rails, etc, I wanted to expand my horizons. And expand I did.
I was hearing all sorts of chatter about ReactJS server-side rendering, and how it required either running a node process to run the rendering, or, more optimally, just writing your backend in JS with node & some framework like express. I figured I'd check it out. Spoiler: It's fucking lame & a total waste of time. Write faster frontend code instead, it saves you tons of time chasing down bugs that happened because the SSR environment is slightly different than the five browsers you're already trying to support.
read more...If there's one pain point in using WordPress, it's the lack of separation between content and configuration/code. While its usually plugins and themes outside of wordpress core that are guilty, WordPress core itself is also guilty in one crucial area: updates. Let me explain:
Whenever a user with Administrator privileges updates core or installs/updates plugins/themes, code is downloaded to a temporary location in the form of an archive, extracted to a temporary location, and then copied into the appropriate place inside ABSPATH. This wouldn't be an issue, except this is WordPress and there's always some vestige of a legacy version that adds complexity/difficulty. In this instance, it's the wp-content/upgrade/ directory inside ABSPATH that WordPress extracts archives (that it already downloaded to /tmp!) to. In these days where /tmp is often in RAM and filesystems can be shared/distributed and/or remote, this makes no sense at all (in fact, I developed the solution you'll see further down the page for a hosting environment I designed and implemented).
So, what to do about this problem, eh? I couldn't find any configuration constant that would change the location, so I searched the whole source tree of WordPress core for the string upgrade/ and found it in wp-admin/includes/class-wp-upgrader.php, in the method WP_Updater::unpack_package.
read more...Sometimes, it's necessary to write a bunch of React components in one file. Ideally, that's not how it's done, but sometimes (and for some people) this isn't feasible in the initial steps of writing code. Most code I've seen handles styles in one of the following ways:
Basically the same as #1, except the style object is imported via webpack or similar from another file.
This one makes me wince with the amount of coupling between the two:
read more...Ah yes. Lazy images. Magical content that only loads when you need it. I learned to code with Haskell, so I'm partial to laziness.
Also, my job depends on it. I work with a bunch of talented designers who make graphic-heavy websites. Tens of MB per page, even after JPG optimization! Besides making smaller images and using srcsets, we use lazy loading. It's so useful, I'm surprised that it never found its way into a standard until recently.
The first piece of the puzzle is detecting when the img elements come onscreen. It's not as simple as a listener or callback. We have some hard requirements:
read more...Engineering is an art form, like playing guitar or painting. But unlike playing guitar or painting, engineering provides a framework to make a fair wad of cash fairly reliably - for both the engineer and especially for his/her/.*'s employer.
The problem is that most of the people becoming engineers (specifically software engineers) are meek, idealistic brainiacs who love computers, and their educations are not teaching them how to survive post-college in the vicious tech industry. Putting our cute little nerd into the tech industry is like giving the same nerd a Rolex and sending him to a dangerous city like Camden, NJ.
When a new graduate sees a job posting offering $100K/year, he'll readily sell his soul without taking a minute to examine if the money he makes his employer will give rise to an exploitative working situation. He might make his employer 10 times more than he makes from his employer.
read more...I don't hate WordPress. Sure, there are aspects of it that suck, but any platform has similar limitations. For most sites, WordPress would be suitable - especially if you intend to do something simple. I'll take a look at performance, security, data organization, and developer productivity.
Any web platform will have performance drains. Scripts have to be loaded, processes need to be loaded into memory, OS calls need to be made, etc. The only platform that I know that doesn't suffer from 66% of those is Haskell (this site is Haskell) because Warp is optimized to use as few OS calls as humanly possible and nothing has to be compiled/loaded at runtime.
Most (robust) scripting languages will have some kind of bytecode, and depending on the language, this might be able to be cached. Have you ever seen the __pycache__ directory in a python project? That's what that is.
read more...This is the deal: Haskell monads are often misunderstood to the detriment of Haskell projects across the 'net.
The reality is that they are extremely easy to understand when you describe them in plain language: They are wrapped functions that take a context and return some value plus a new context.
Here's a definition for a 'State' monad that implements mutable state:
read more...Honestly, computers are time-consuming money pits - especially for us techy types. Costing thousands of dollars a piece, our computers are no match for the sheer amount of data we throw at them. They always need to be faster, store more, and process our ever-growing mountains of data at a constant speed.
If I received a dime for every time a fellow programmer told me to just buy another drive because "storage is cheap", I'd be a millionaire. Many people I know who follow this philosophy have scores of hard disks and USB drives lying around, largely untouched once filled. The Haskell programmer in me wonders why anyone would accumulate all that data if they were never going to use it.
Cloud storage providers often offer a free tier, usually around 5GB to 30GB of free space you can fill with your documents and pictures. This should be all you need, but for most people, it isn't. I bet the folks in marketing at Dropbox have calculated that 5GB translates to a "teaser" amount of storage - they know the average user hoards orders of magnitude more digital trash than 5GB.
read more...UPDATE: most of the cool stuff I talk about I put in the package webapp on the Hackage.
The aspiring blogger uses a blogging platform like WordPress or Blogger to go from zero to blog in under thirty seconds. Most people can't code, and those who can usually want to use someone else's code anyway.
Fine. Use bad software if it makes you happy. Wordpress is a precarious concatenation of bunk so fragile, many devoted users will refuse to host them themselves. Nobody has time to appease Wordpress's byzantine architecture.
read more...