If you were to start React all over again what would you do? [NSFW]
![Featured image for If you were to start React all over again what would you do? [NSFW]](/blog/2018/11/30/if-you-were-to-start-react-all-over-again-what-would-you-do/V2aWV5Bz83-400.png)
If you were to start react all over again what would you do?
This was a text sent to me by Alvin (not his real name) a software tester, wannabie junior software developer, who has studied the basics of coding including HTML, CSS and Javascript.
If you donât know what that sentence means, probably stop reading now.
This post is going to get technical. Iâm aiming this blog post at Alvin, so if that doesnât sound like you, maybe go do something more important, like having lunch or caring for the people around you.
React is a technology created by Facebook for building websites.
React is also a technology for building mobile phone apps, using Reactâs teenage sister technology React Native.
TLDR; To Long Didnât Read this blog post? If you are just looking for a quick list resources to start with React, go to the end of this blog post.
Still, here?
Great!
Letâs begin.
Dear Alvin and Dear reader, here is my answerâŚ
Go to a top university and study Computer Science for at least three years, pay particular attention to object oriented programming, and then come back to me.
Wait, you donât have ÂŁ27,000+ tuition fees, plus living expenses and three years to spare?
Too bad. I had a lot of fun. Especially the summer BBQs. And the student theatre. And the all nighters doing coding projects in Java or SQL or LISP or something. It all seemed very academic at the time, but over time some of those early lessons have rung true.
I remember talking to a junior developer in a previous job who had dropped out of computer science at university and come to work for us.
âDo they still teach that you should nail down the API before you work on anything else?â I asked.
âYesâ he said.
âSo thatâs a piece of advice that is a least 20 years old that this company still isnât doing.â I said with quiet resignation.
So Alvin, given you are not going to spend another three years at university, here is Louie Christieâs Computer Science degree in a weekend syllabus.
Bear in mind this is not complete but it is informed by half a life-time so far of studying and working with computers, and observing users of computers. Itâs also irreverent, opinionated, and probably wrong in places*. But itâs cheaper than ÂŁ27,000.
(* See the comment about nailing down the API above if you are a GraphQL aficionado/donât like thinking ahead/like doing rework.)
Louie Christieâs Computer Science degree in a weekend syllabus
Read Chapter 1: The Tar Pit in the book Mythical Man-Month by Fred Brooks. It was our first bit of reading for my first seminar in week one. If you really canât bring yourself to read the chapter, at least look at the picture on the front. Itâs a sabre-tooth tiger drowning in a thick, marmite-like, bog, becoming extinct. The point is, thatâs you. The marmite bog is the career youâve just volunteered yourself for, and that sabre-tooth tiger, thatâs you, drowning, head only just above the water of project managers, bad designs, broken dreams, wasted money, and the latest failed National Health Service IT project.
Right, now Google for an article, that I read before I did my coding boot camp, that I canât find any more, if you find it send me the link. @TODO find link@. It was about your personal project, the one with clean code, that you wrote and understand, that is perfectly modular, virtually bug free, and possibly even documented. The point of that article is that any work project is never going to be as pure as that. Other people will get involved, people will tell you to âhit the ground runningâ, that âwe are going through a busy patchâ, that sort of thing, and youâll deal with shit code that you hate. Which later youâll discover is actually much better than you you thought it was, (because itâs easier to write code than to read it, but thatâs another story.) Great, thatâs your university assignments done.
Now Google what DRY means (clue â donât repeat yourself.) Now you understand the basics of object-oriented programming. Later in your career people will say things like âtechnical debt is acceptable to get a minimum viable productâ or âdeliver as much client value as quickly as possibleâ or just âwe donât have timeâ. When these things happen, youâre probably going to have to repeat yourself. But keep the DRY mantra in mind and when you later deal with the headfuck youâve created and consider then going DRY or changing jobs.
It was around this time on my university course some grey haired academic told us that Java is a proper object oriented programming language, and Javascript is a frivolous scripting language that copied the name, was thrown together in 10 days, and will never take off. Ignore this advice. 20 years later it turns out Javascript is the most used programming language on Github, and in my opinion, in 2018-19, your best bet for getting a job. Also bear in mind that Java is a proper object oriented programming language, and Javascript is a frivolous scripting language that copied the name and was thrown together in ten days.
Because they sound similar, recruitment consultants will often try and recuit you for the wrong one*. Also, technical mangers will think they are the same thing, especially if they have been working with Java/JavaScript for many years.
( * See a possible future post on recruitment consultants and âanything that says Java is goldâ.)
Also, donât create global variables, and donât have side effects in your methods or functions*. Thatâs because if you do those things your code becomes more of a headfuck. Also I read some article criticising some car manufacturerâs code that had thousands of global variables that were literally a death trap.
(* Please let me know the difference between a method and a function if you find out. Itâs the sort of tech trivia mid-level programmers love to ask in job interviews, especially if they can catch you out and feel smug.)
Basically the idea is that you have separate chucks of code that operate independently and donât tinker with each other. Except when you join them together in a system and they pass data between each other in documented, predictable, ways.
Ok, thatâs the rest of object oriented programming covered. And functional programming, which they never taught me twenty years ago, but I learned about it from a couple of younger graduates in the same place we met, a bar at a Silicon Milkroundabout careers event.
And letâs be honest, for most of your career youâll be copying, pasting, and slightly modifying code from the current codebase or from the internet and will only ever talk about object oriented or functional programming in job interviews, or at the bar.
Right, now you are ready to use React. Now smarter people than I can tell you whether React is object oriented, functional, prototypical, or following some other paradigm or some bastardisation of them all (reactive?).
Edit: 2019/05/10 â I spoke to one of those nice Finish guys at the tech consultancy Futurice. It is reactive. Which, the Fin and I discussed. (Turns out since the demise of the Nokia 3210 phone, the Fins who were made redundant havenât disappeared, but have been busy setting up tech consultancies amongst other things.) The Fin and I reckoned Reactive is probably what a white bearded developer I met at a tech event in Croydon said when I explained React to him: a re-hasing of an old idea â the Observer Pattern. But, as the Fin said, itâs Observer Pattern for the fashionable Functional Programming Paradigm, because functions are easy to test, but you end up with a lot of them and it gets complicated, so you need Reactive. Alvin⌠it doesnât matter if you donât understand any of this paragraph up to this point. Just be aware, that just because an idea in technology is old, you donât have to automatically reject it, like a teenager rejects old ideas. Even if a lot of your co-workers are teenagers, prodigies, or Mark Zuckerberg.
But I think most people would agree that react is built up of components.
This is a good thing.
It means you can work on one thing, a big blue submit button for example, with less of a chance of accidentally breaking another button, or breaking the whole app, or launching a nuke, or loosing $100,000 dollars a second by changing the powerpeg variable.
In theory your components wonât have global variables or side effects. In reality they will probably have some global things, like the particular shade of red the marketing department wants you to use for the company logo.
If you are lucky they will actually provide you with a standard # hex code, but equally you might get a various similar, but not exactly the same colours from different designers, marketers, managers, in CMY â which is designed for printing and has no agreed way to display on screen. Youâll also get a ton of different but almost exactly the same shades of grey. These are your global variables. Try and keep them to a minimum, hopefully no-oneâs life will depend on it, unless you work in advertising, in which case someone probably has had stomach ulcer over that shade of red at some point.
At this point it is important to remember that nailing down an exact colour is both technically easy, (but office politically difficult,) and itâs not that important to customers, because itâs all relative, changes depending on the printer used, light in the room, a blue and black dress looks gold and white, etc. Unless you are colour blind. In which case a green button for a save button and a red button for a delete button look the same. Also a red button for self-destruct the nuclear power station will look the same. (So you may want to put different beer taps on identical power station buttons to stop that happening, see The Design of Everyday Things book by Don Norman. (Professor and director of the Design Lab at the University of California, San Diego and former vice president at Apple.)
, but thatâs for another blog post on the weekend syllabus to MSc in Human-Centred Computer Systems and User Experience.
React⌠back to React. What does this have to do with React? WellâŚ
The Holy Grail
âPlay with Expo Snack.â
âPlay with Expo Snack.â This was almost the reply I sent immediately to your text of âif you were to start react all over again what would you do?â.
It was the first thing that came to mind. Before I thought about it, and ended up writing the nebulous Winter 2018 series of blog posts up to this one.
Expo Snack is actually not even using straight React, itâs using React Native. But the basics are the same and it has some benefits, not least that you can edit code on your computer, and see the results on your phone, without pesky adjusting windows or swiping between desktops. And you can make cross-platform apps and websites with React Native for Web with the same code-base, but thatâs a subject for another blog post.
See the button on the right that says something like âTap to playâ. Never press that. It rarely works, or you have to wait in a queue for ages and I think they limit your usage, so just get in the habit of using the âRun on your deviceâ button.
It works by you installing the Expo app on your phone, and then you scanning a QR code. For iOS, Expo Snack implies you canât use QR codes. Ignore that. Itâs just poorly worded. You can, you just need to open the official apple camera app (and not Expo app) and point it at the QR code.
Anyway, the a nice thing about Expo Snack is that it has a search bar on the right and a load of components that you can drag and drop into your code. Which illustrates my point about components. Except that it isnât working any more, bollocks, but itâs probably for the best. So youâll have to look at the gif instead:
Animation (GIF) taken from âSnack â A Playground for React Nativeâ, Satyajit Sahoo, Mar 14, 2017
Look! Someone dragging and dropping code around. Like magic. Slotting pieces together like Lego. This is the holy grail. Re-usable components. That do one thing each. That can work together. Without weird bugs, crashes, global variables or side-effects. Without headf@ckery, without losing billions of dollars on the stock market in seconds, or blowing up Chernobyl.
Edit code visually, like slotting together Lego? Sadly React is not that. The closest Iâve seen (that actually works, and isnât some bastard absolute positioned, un-semantic, hack, that wonât work on different sized screens) is Scratch for kids, see this video from DK Penguin Books. I used to work on DKFindout [RIP] a childrenâs encyclopaedia website. I hope kids are reading stuff like that, and not this.
Possibly weâll never get to editing code visually because of paradigm shifts and The Law of Leaky Abstractions.
React isnât the holy grail. But itâs close, and itâs in the right direction. See Jani Eväkallioâs talk on the Future of UI Development.
Look at the jigsaw puzzle box picture
I was also going to text you about looking at some decent open source React code. Personally I think before you do a jigsaw, you should look at the picture on the box. And likewise, before you code React, look at some quality React code, like todoMVC, if it had (update 2026 â it does now) a Redux or apollo-graph-persist version, but it looks like Iâll have to cover that in another post. You donât have to understand the code. But just take a peek. Think of it as inspiration. Especially look back when you are having a bad day at work, and remind yourself that clean code does exist, somewhere, out there. I wish Iâd known about todoMVC earlier, and that it was a cloud data driven multi-page thing, more like a real world website you might work on.
Actually something like that exists from Thinkster here. Look at it, bathe in the sunlight. Youâll probably never get paid to make clean code like this, and neither will I. But itâs comforting to know itâs out there.
Things to do instantly
Also, hereâs a list of things to do instantly, this list should be like sucking eggs to you, and if you havenât done any of them, do them now:
- Read the React page on Wikipedia
- Read the basics of React on the official documentation website, but maybe just as far as doing the âHello Worldâ tutorial. There are probably going to be better tutorials elsewhere after that.
- Follow key players in React on twitter, Dan Abranov, Jani Eväkallio, the [guy who built twitter mobile web site](http://Nicolas Gallagher), etc.
- Learn about Javascript ES6 arrow functions
- Install Microsoftâs VS Code, and install the Priettier and ESLint extensions
- Read Hacker News regularly
Also know that Javascript improv is a thing (but more on that in a different blog post):
Many many days agoâŚ
A foolish young man by the name of @ferrannp made a deal with the devil.
"If I get 1000 followers, @ken_wheeler can punch me in the face. He's halfway around the world, surely, we'll never meetâŚ"I give you the finale of #componentDidSmoosh pic.twitter.com/vlXNac0AOQ
â eli (@elibelly) November 30, 2018
- â Previous
Computers For Good - Next â
Choosing a software project

