What MVC framework for web development?

Answered in Quora:

Q: Why should I learn the combination of Python/Django rather than PHP, JS/Node? I am a web designer moving to web development. What is the scope of Python/Django?

Python/Django is like learning Ruby/Ruby on Rails. The equivalent in the PHP world would be PHP/Drupal or PHP/Laravel. Equivalents in NodeJS is not Node/JS but NodeJS/Meteor or NodeJS/Sails. In all those examples above the first part would be the underlying web language, and the second would be a MVC framework on top of the language.

(There exist web frameworks that do not provide MVC but just the web server and HTTP request-response plumbing. This isn’t common in PHP since it is embedded in a web server such as Apache or nginx, but in Python it would be flask and in NodeJS it would be Express or Koa— these are sometimes referred to as “microframeworks.”)

However, unlike on the front-end with things like Vue.js, React/Redux and AngularJS, full-service MVC web frameworks have increasingly less utility on the back-end. This is because most the the advantage a framework provides is to do heavy-lifting of tedious but repeatable tasks that require a lot of code (very common when building a user interface) the bulk of which has been moved onto the client in web development. What value is a MVC’s templating system and router when both have moved into javascript on the client-side and all interactions are through an API? This becomes more extreme with standardization of the data interface (a la GraphQL) and the prevalence of more service-oriented architecture popularized by microservices or serverless FaaS architectures.

MVC web-frameworks still provide things such as a configuration management, a data object model and abstraction, but even those can get in the way as a website becomes more mature and this pre-fab approach becomes a hinderance to future scalability and optimization.

Also, when not building to scale or building proof-of-concept, a full MVC architecture will help you starting out on server-side web development because it does all the heavy lifting for you. So it might be good to start out with one, though YMMV (your mileage my vary).

Continue reading about the state of web frameworks after the jump

These tweets spark joy

Marie has loved Marie Kondo since her book first hit the US four years ago, so of course last night we watched the first episode of her new show on Netflix.

This morning she’s been sharing with me these tweets.

“There is definitely something unique and fresh about Marie Kondo. That’s why she’s become so popular.” she said.

“I just hope that I continue to spark joy in your life,” I replied.

The Zen of Defriending

Seen on facebook:

Welp. There goes another Facebook friend, who decided facts about the southern border were inconvenient and did not fit her worldview, and decided that as a messenger I must be unfriended.

I’d like to remind people that “unfriending” simply means “retreat into my echo chamber”. If I was disrespectful, vitriolic, or hateful, then sure: unfriending would have a completely different meaning. But that isn’t the case. I don’t call people names. I try to respect others’ views. I don’t yell. I try to stay on-topic.

Unfriending is a retreat from thoughtful discussion. It isolates you from opinions that differ from your own. Stick to your views, respect your friends’ views, and talk to them. We need more talking

People should be free to friend or unfriend whoever they like. Freedom of Speech doesn’t mean I have to read your shit (or you, mine), and it certainly doesn’t apply to the failure pile in a sadness bowl substitute for real social interaction that is Facebook.

I never unfriended anyone on Facebook (or Twitter) until November 2016, but I never had a problem with anyone unfriending me, before or after.

Nor can I relate to those who do. Personally, it’s been quite a relief when I got defriended — my haters are pruning my social network for me! This way they can spout their shit freely without me. If, by some miracle, they have an original thought about a good programming design pattern, someone will eventually point me to it through a different avenue. I use Facebook for the baby pix and death notices and Twitter for the memes.

I suggest you feel the same/similar about being defriended, because being a butthurt snowflake when someone you don’t agree with unfriends you says more about you, then it does them.

If in our social networks we can unfriend others who are useless shits to us, if we can be happy when we are unfriended when we are useless shits to them, not only we, but everyone will profit from it. This is the most basic kind of social work.

You’re welcome. Just call me the Thich Nhat Hanh of your social network.

Vagrant, Time Machine, and waiting forever for a backup

For some reason, moving to the new MacBook Air hasn’t been very successful. My Alfred spotlight is broken, Apple Mail slows to a crawl for no good reason even though everything is in the cloud, and I have a \<50% success rate of backing up my Time Machine during my workday. Basically if it doesn’t complete before lunch, it isn’t going to finish at all.

That last one seems to be well within the realm of what’s feasible. I mean why is it backing up 15GB of new files each day and why is it when I really get working the last 2GB never seems to complete? Not to mention that this 5TB drive I purchased four years ago to back up what is only a 500GB SSD (was smaller in years back) is now starting to appear full.

Well I think I figured it out. I’ve been using Vagrant for the last 5 years to build out virtual machines for development and each of them is a single (very large) virtualbox file that needs to be re-imaged every time and is constantly changing if the machine is up during the backup process.

After some research here are some suggestions on what to exclude from your time machine backups

Working scratch folders:

Things like ~/.Trash and ~/Library/Caches should automatically be excluded by Time Machine in general, but for me, I use ~/Downloads as scratch space for stuff that I don’t care if I lose. If it’s important, I usually drag that to desktop, so I added that. You can add something similar

Cloud files

I added ~/Dropbox because that stuff will be built from Dropbox, and Time Machine or migration restores will just confuse the backup system. If I used Google Drive, I’d probably add that too.

Virtual machines and other dev related environments

For me that’s ~/.vagrant.d and ~/VirtualBox VMs where vagrant downloads the boxes and where, by default, it puts the VirtualBox VMs. The actual boxes that I might image to do Windows/IE development are manually created and imaged in ~/Documents so there is no need to exclude those. If you want to keep your plugins then save ~/.vagrant.d/boxes only.

I also added ~/Library/Containers/com.docker.docker because sometimes I did Docker development and that’s where those instances are.

Also if you have a standard place where you put Python virtual environments with virtualenv you should probably add that too. I don’t develop on localhost anymore so that isn’t the case for me.

Local software caches

I added ~/.gem for Ruby and ~/.npm for NodeJS. I’d probably look into what I can torch from rbenv and rvm but I no longer do local Ruby development, but if you do, add those to your checklist.

Games

I don’t have this on my work computer, but on my home one, I added ~/Library/Application Support Steam/steamapps because those are big files that are downloaded from the internet anyway. When I get home, I’ll have to make sure that sort of thing wasn’t moved into /Users/Shared.

Unknown unknowns

I probably should figure out where Ulysses puts its files because every time I do Migration Assistant I have unresolved conflicts which take forever to clean up. It’s not a big deal though since almost all copies are actually the same file.

Know of any other things I need to add?

I’m speaking again!

If you haven’t been paying attention, I’m starting to speak again at PHP conferences. The first one is SunshinePHP in Florida. (I figured I needed to see the Sunshine State again before it all goes under water.)

My talk is going to be a case study on recommender systems. It’s a bit of an odd-ball because it’s not PHP-specific, but that’s because the company I worked at was a Ruby-on-Rails shop. It’s okay, it will still have application and ironically the heavy lifting is done in Python and Go. Lol! Trust me, it’ll be a good talk. Data is an important part of any website and this gets you going into how you can use it without all the bullshit “big data” buzzwords.

I really think you should register for the conference and come see the talk. If you are already going, please stop by and say “hi!” I promise, I won’t bite too much. I’ll be there for the entire event and this time I already have my talk 95% done so I won’t be holed up in the hotel room finishing slides. It’s been much too long since I’ve seen anyone in the community, and I’ve got to earn my place on the PHP terrorist deck.

See you in February!

Running Python scripts on a schedule in AWS

Answered in Quora:

Q: What is the easiest/fastest way to set up AWS to repeatedly run a small Python or PHP script (24×7)?

Probably the easiest way is to use Lambda. It has a built-in scheduler and you only pay for the time it is running. (Note that in PHP you have to create a lambda package using this tutorial or via node Serverless here.)

If you mean continuously, and not repeatedly, then the caveat for PHP at least, it is a bad idea to have it repeat forever in the process because it was designed to be set up and torn down and might leak memory (with the proper setting to set_time_limit and ignore_user_abort, have it run forever). In those cases you would have something else constantly call the php script via command line and restart.

Other than that, whether PHP or Python or whatever, it is better to create a non-burstable EC2 instance and run it, since it will always have some load. You can write something simple to the crontab that will make sure the process is always running or, better yet, use forever.

Old alumni page

One thing I’ll always be grateful to my father for was buying me a lifetime Caltech alumni membership on my graduation.

Dear Terry,

We are writing to share news about your Alumni Website. You may have received this email already, and if so, I apologize for the duplicate announcement. For those that have not received it, we are aware that many of our emails are being caught by Spam or getting lost so we want to make sure you are aware of this news.

We are upgrading the SquirrelMail server to Microsoft Office 365. This means that your alumnus.caltech.edu webpage will not transfer and we will no longer be able to host your site. You will need to transfer any photos or documents you wish to keep. The current alumni server will be decommissioned on December 17, 2018.

If you would like to keep your website address, we are able to provide you with a redirect. This will only provide you with a redirect and will not transfer any documents or photos to your new site. Please fill out this form: Alumnus Website Redirect before December 15, 2018. If you do not have a webpage address ready, we can also create one at a later date.

To log in: please go to: https://alumnus.alumni.caltech.edu/wp-admin
Your website is: http://alumnus.caltech.edu/~tychay/

The Caltech Alumni Association has been working diligently to help support a widely inclusive and connected alumni community.
Thank you for your understanding. If you have any questions, please email us at email@alumni.caltech.edu or call us at 626.395.6592.

Thank you,
The Caltech Alumni Association

First of all, wow, we were using a WordPress install for authentication for a CMS? Since when?

Second of all, I had a alumni page? Since when?

Hmm…

&lt;HEAD&gt;
&lt;TITLE&gt;terrychay&lt;/TITLE&gt;
&lt;/HEAD&gt;

&lt;BODY&gt;
&lt;P&gt; My homepages
&lt;OL&gt;
&lt;LI&gt; &lt;a href=&quot;http://www.pws.uiuc.edu/~tychay/&quot;&gt;Old physics page&lt;/a&gt;
&lt;LI&gt; &lt;a href=&quot;http://guava.physics.uiuc.edu/~tychay/photo/&quot;&gt;Photo Album&lt;/a&gt;
&lt;LI&gt; &lt;a href=&quot;http://guava.physics.uiuc.edu/~tychay/swing/&quot;&gt;Swing Society&lt;/a&gt; (site I designed)
&lt;LI&gt; &lt;a href=&quot;http://phy290p.physics.uiuc.edu/&quot;&gt;Personal Webserver&lt;/a&gt; (intermittent)
&lt;LI&gt; &lt;a href=&quot;http://game1.zipasia.com/actions/&quot;&gt;Adobe GoLive Actions&lt;/a&gt;  (may be moved)
&lt;LI&gt; &lt;a href=&quot;http://www.zipasia.com/&quot;&gt;ZipAsia&lt;/a&gt; (current employer)
&lt;LI&gt; &lt;a href=&quot;http://game1.zipasia.com/&quot;&gt;Zip2Games&lt;/a&gt; (current project)
&lt;/OL&gt;
&lt;P&gt;I&#039;ll consolidate this sometime. It&#039;ll be so 3leet that it will be 4leet!
&lt;/BODY&gt;

Wow, that’s some old shit. I must have done that over 18 years ago. None of the links there even work. The days when we used to capitalize HTML tags, which is the reason why PHP functions are case insensitive by the way.

I never did get 4leet status by consolidating all my internet sites. They just all went down the memory hole. I think I’m going to let this one go that way also.

What’s something very few people know about PHP?

Answered in Quora:

Q: What’s something very few people know about PHP?

It is mind-bogglingly popular for web development. That popularity hasn’t diminished even though conventional wisdom says otherwise…

Over a decade ago, I said about 40% of the top 100 websites use PHP — a number I pulled out of my ass — but nobody (not even the Ruby on Rails developers I pissed off) argued with that spurious claim. In 2009, Matt Mullenweg, the creator of WordPress became curious with my claim and did a survey of Quantcast’s top 100 sites — he got almost exactly 40. Even today, among the 10 most important websites, four use PHP as their language of choice — 40% again.

Overall, almost 80% of the internet is powered by PHP, and that has held steady for years! Newer web languages such as Ruby or NodeJS have only grown at the expense of other languages such as ASP, Java, or Perl.

Just one single application written in PHP, WordPress, is used by over 30% of all websites on the entirety of the internet. That’s more than double the market share since back when I last worked at Automattic/WordPress in 2011! It grew until it saturated its entire market — over 60% of all CMSs. In the CMS market as a whole, PHP-based CMSs occupy positions 1, 2, 3, 6, 7, and 8 in the top 10. The most popular non-PHP-based CMS is both closed source and sitting at only a 2.5% share.

It was estimated back in 2009 that there were 5 million PHP developers worldwide. It’s difficult to make this estimate today, but it’s obvious that that number has also held steady or grown.

These last few years, I’ve been commercially working in Ruby (on Rails), GoLang, NodeJS (for static servers), and Python (Django), but PHP is still also my love in that love/hate relationship.

Come see my talk in February 2019 at SunshinePHP in Florida!