Author: Grant G

  • OpenAI Academy Courses: Practical AI Skills for Work

    TL;DR: OpenAI has launched three new Academy courses designed to equip professionals with practical AI skills. The courses teach how to build hands-on AI abilities, create repeatable workflows, and deploy AI agents in daily work tasks, marking a step toward democratizing AI literacy.

    • Three new OpenAI Academy courses focus on applying AI at work.
    • Topics include building practical skills, designing reusable workflows, and using AI agents.
    • The courses are self-paced and suitable for a broad range of professionals.
    • They emphasize immediate, real-world application rather than theoretical concepts.
    • This initiative reinforces OpenAI’s effort to make AI education widely accessible.

    What Are the New OpenAI Academy Courses?

    OpenAI has expanded its educational offerings with three fresh courses on the Academy platform. Aimed at individuals who want to integrate artificial intelligence into their professional routine, the curriculum moves beyond theory to hands-on application. The courses cover three distinct yet complementary areas: building fundamental AI skills, crafting workflows that can be repeated across projects, and deploying AI agents to handle routine tasks autonomously.

    How Do the Courses Help You Build Practical AI Skills?

    The first course is tailored for learners who need a pragmatic foundation. Instead of abstract concepts, participants work through real-world scenarios where AI becomes a collaborative partner. Exercises likely involve using natural language to instruct models, interpreting outputs, and refining prompts for accuracy. The goal is comfort and competence with AI tools that can assist in writing, analysis, coding, or creative problem-solving.

    What Does Creating Repeatable AI Workflows Entail?

    The second course shifts focus to systematisation. It shows how to design processes where AI steps in predictably—such as summarising documents, generating reports, or triaging emails. By learning to chain prompts and leverage API features, professionals can create templates that save time and reduce manual friction. This is especially valuable for teams that want consistent AI outputs without starting from scratch each time.

    How Can AI Agents Be Applied in Everyday Work?

    The third course introduces agentic AI. It teaches how to configure and supervise AI systems that can plan multi-step tasks, reason through problems, and act on your behalf. Think of researching competitors, drafting project plans, or monitoring data feeds. The emphasis is on delegation with oversight, ensuring the agent aligns with user intent and organisational guidelines.

    Who Should Enroll in These Courses?

    OpenAI deliberately broadens the audience. No machine learning PhD is required—just a willingness to experiment. Business analysts, marketers, developers, product managers, and executives can all benefit. The self-paced format lets learners dip in and out around their existing workload. Because the courses are housed on the Academy site—where content is typically free—cost is not a barrier, widening access to anyone with an internet connection.

    By the Numbers

    • 3 new courses added to the OpenAI Academy catalogue.
    • 3 core themes: practical AI skills, repeatable workflows, and autonomous agents.
    • Zero prior AI experience explicitly required, making the courses accessible to non-technical professionals.
    • 100% self-paced learning, allowing users to complete modules on their own schedule.

    Frequently asked questions

    What is the OpenAI Academy?

    The OpenAI Academy is an online learning platform that offers free courses, tutorials, and guides to help people understand and use artificial intelligence effectively. It covers everything from prompting basics to advanced agent design.

    Are the new Academy courses free?

    Yes, like other OpenAI Academy resources, these courses are available at no cost. They aim to remove financial barriers to AI education and are open to anyone with an internet connection.

    Do I need programming experience for these courses?

    No. While some familiarity with digital tools helps, the courses are designed for a broad audience, including business professionals who have never coded. The focus is on applying AI through natural language and guided interfaces.

    How long does each course take to complete?

    As self-paced modules, completion time varies by individual. Most learners can finish a course in a few hours spread over multiple sessions, though the exact duration may be listed on the course enrollment page.

    Sources

  • OpenAI IPO: High-Profile Hires Signal a Strategic Shift Before Going Public

    TL;DR: In the weeks before its anticipated blockbuster IPO, OpenAI landed two senior figures: Noam Shazeer, a co-inventor of the Transformer architecture who returns from Character.AI, and Dean Ball, former Trump administration AI policy official. The moves underscore a dual push to dominate frontier model research and to navigate the tightening global regulatory landscape.

    • Noam Shazeer rejoins OpenAI, bringing deep Transformer expertise to accelerate next-generation model development.
    • Dean Ball’s policy background signals OpenAI is investing heavily in regulatory strategy as AI governance heats up.
    • The hires come amid reports OpenAI will be one of the largest tech IPOs ever, with a valuation near $300 billion.
    • OpenAI is assembling a leadership bench that blends foundational AI research with political and policy acumen.
    • This pre-IPO talent grab suggests the company is preparing for post-IPO scrutiny and intense competition from Google, Anthropic, and Microsoft.

    Why Did OpenAI Hire Noam Shazeer and Dean Ball Right Before Its IPO?

    With its IPO reportedly just months away, OpenAI made two headline hires in June 2026. Neither is a typical executive appointment. Noam Shazeer co-authored the seminal “Attention Is All You Need” paper and went on to build Character.AI. Dean Ball shaped federal AI policy under Donald Trump. Their arrivals, confirmed in the same week, reveal a deliberate strategy: OpenAI is bulking up on foundational research talent and policy muscle at a moment when both matter more than ever.

    What Does Noam Shazeer’s Return Mean for OpenAI’s Technical Ambitions?

    Shazeer helped invent the Transformer, the architecture behind virtually every modern large language model. After leaving Google, he co-founded Character.AI, which OpenAI reportedly explored acquiring. His decision to join OpenAI instead puts him at the center of GPT’s next evolution. Expect more aggressive architecture innovations, possibly including hybrid models that merge retrieval, reasoning, and long-context memory. His presence also sends a signal to the research community: OpenAI remains the place where foundational breakthroughs happen.

    How Does Dean Ball Strengthen OpenAI’s Regulatory Position?

    Ball’s government experience is not just a resume line. He advised the White House on AI policy when executive orders on artificial intelligence were being drafted. As the EU AI Act rolls out and U.S. lawmakers debate licensing and liability rules, having an insider who understands both the levers of power and the technical nuances is invaluable. Ball can help OpenAI anticipate compliance requirements and shape legislation before it solidifies. This is about more than lobbying; it’s about building a regulatory framework that allows rapid innovation while maintaining public trust.

    What Does the Talent Grab Tell Us About OpenAI’s IPO Strategy?

    Pre-IPO companies often bolster their boards and leadership with recognizable names. OpenAI is doing something different: it’s reinforcing the creative and policy layers that directly affect the product and its operating environment. This suggests CEO Sam Altman wants IPO investors to see a company that controls its own destiny—not one overly dependent on any single model or vulnerable to regulatory shocks. By landing Shazeer and Ball, OpenAI is crafting a narrative of self-sufficiency and long-term defensibility.

    By the numbers

    – OpenAI’s latest funding round valued the company at approximately $300 billion (March 2025).
    – The Transformer paper that Shazeer co-wrote has been cited over 100,000 times, making it one of the most influential AI papers ever.
    – Dean Ball served in a senior AI policy role from 2017 to 2021, overlapping with the issuance of two major executive orders on AI.
    – OpenAI’s IPO is expected to be one of the largest in tech history, potentially surpassing Arm’s 2023 market debut.

    FAQ

    When is OpenAI’s IPO expected?

    No official date has been set, but multiple news outlets report preparations point to late 2026 or early 2027, subject to market conditions.

    Who is Noam Shazeer?

    Noam Shazeer is a machine learning researcher who co-invented the Transformer architecture in 2017 while at Google Brain. He later co-founded Character.AI, which became a leading conversational AI platform.

    What does Dean Ball’s hiring say about OpenAI’s relationship with Washington?

    Ball’s deep ties to Republican AI policy networks signal that OpenAI intends to work closely with whichever administration is in power, ensuring its interests are represented in legislative and regulatory discussions.

    Could these hires delay or accelerate the IPO?

    They are unlikely to affect the timeline directly but may strengthen the company’s valuation story, potentially speeding up investor demand and a successful roadshow.

    Frequently asked questions

    Why did OpenAI choose Noam Shazeer and Dean Ball specifically?

    Shazeer brings unparalleled expertise in the Transformer architecture, which underpins GPT models. Ball offers a direct line to the political and regulatory machinery that will shape AI’s future. Together they cover the two biggest challenges for any public AI company: technical edge and policy navigation.

    Is OpenAI’s IPO valuation realistic?

    The $300 billion figure reflects its last private fundraise. Whether public markets will support that number depends on revenue growth, competitive dynamics, and how the current AI hype cycle plays out.

    What role will Dean Ball play at OpenAI?

    Ball is expected to lead or advise on AI policy and government affairs, helping the company engage with regulators in the U.S., EU, and other key markets.

    Sources

  • Mistral AI Expands Physics AI with Emmi Acquisition: A Strategic Move for Industrial Engineering

    TL;DR: Mistral AI has acquired Emmi AI to launch a new physics AI capability, entering the industrial engineering simulation space. The move aims to accelerate product design cycles by replacing multi-day traditional simulations with real-time AI predictions. The acquisition brings Emmi’s team of 30+ researchers and a suite of large engineering models to Mistral’s existing stack, targeting high-stakes sectors like aerospace, semiconductors, and energy.

    • Mistral AI acquired Emmi AI to build a physics AI stack that predicts physical system behavior, reducing simulation time from hours/weeks to seconds.
    • The acquisition adds a team of 30+ researchers and state-of-the-art large engineering models to Mistral’s enterprise solutions for manufacturing.
    • Physics AI models learn from traditional solver outputs and can map geometry to physical fields in a single forward pass on one GPU, enabling real-time design exploration.
    • Initial partners include ASML, Airbus, Safran, and Siemens Energy, focusing on high-stakes industrial applications like chip manufacturing and aerospace.
    • The physics AI is not a replacement for first-principles solvers but targets the majority of design-loop iterations, with traditional methods reserved for verification.

    What is Mistral AI’s Physics AI and Why Does It Matter?

    On May 27, 2026, Mistral AI announced the launch of a new class of AI models designed to predict the behavior of physical systems. This initiative, termed Physics AI, aims to accelerate engineering workflows by replacing traditional numerical simulations—which often take hours to weeks of compute time per design variant—with real-time predictions that run on a single GPU in seconds.

    According to Mistral’s official announcement, traditional physics analysis remains stuck in a decades-old pattern: prepare geometry, create a mesh, configure boundary conditions, queue on an HPC cluster, and wait. The result is that engineers typically evaluate only a handful of design variants when they could be exploring thousands. The new physics AI models are trained on outputs from these traditional solvers and can then predict physical behavior directly from geometry and boundary conditions in a single forward pass.

    How Does the Emmi AI Acquisition Fit In?

    Just a few days before the physics AI announcement, on May 23, 2026, Mistral AI entered into a definitive agreement to acquire Emmi AI, a Vienna-based startup specializing in Physics AI. The acquisition brings Emmi’s team of more than 30 researchers and engineers—described by Mistral as among the leading experts in Engineering AI globally—into Mistral’s Science and Applied AI teams.

    According to the announcement, Emmi AI has quickly emerged as one of the world’s most ambitious AI companies at the intersection of artificial intelligence and industrial engineering. Its technology enables industrial players to replace multi-day computations with real-time simulations and build digital twins to optimize asset operations. Mistral’s CEO Arthur Mensch stated that this strategic acquisition cements Mistral AI’s leadership in industrial AI and positions the company as the partner of choice for manufacturers in high-stakes sectors like aerospace, automotive, and semiconductors.

    What Distinguishes Physics AI from Traditional Simulations?

    In its physics AI announcement, Mistral AI explicitly clarified what physics AI is not:

    • Not a replacement for first-principles solvers in every regime. Traditional solvers are still used for verification and edge cases.
    • Not an LLM trained on simulation data. The architectures, training objectives, and evaluation regimes are fundamentally different.
    • Not a regression on a single geometry. The models are designed to generalize across geometries and boundary conditions.

    Rather, physics AI is described as a step-change in throughput for the vast majority of design-loop iterations. Engineers can now run thousands of design variants in the time it previously took to run one or two, with traditional solvers reserved for verification and edge cases.

    Who Are the Key Partners?

    The physics AI initiative is not just a research project—it already has industrial partners. According to the announcement, Mistral AI is working with ASML, Airbus, Safran, and Siemens Energy as partners for this technology. These relationships are intended to help solve real-world engineering challenges in chip manufacturing, aerospace, and energy.

    Mistral AI’s partnership with ASML extends beyond technology collaboration. In September 2025, ASML led Mistral AI’s €1.7B Series C funding round at an €11.7B post-money valuation, as announced here. ASML CEO Christophe Fouquet stated that the collaboration aims to generate clear benefits for ASML customers through innovative products enabled by AI.

    How Does This Compare to Other AI for Science Initiatives?

    Mistral AI is entering a growing field of AI-driven scientific simulation. While specific benchmark comparisons with competitors are not provided in the source material, the company positions its physics AI as a unique offering that combines frontier AI models with agentic capabilities for engineering workflows. Unlike academic research projects, Mistral’s approach is explicitly commercial, targeting enterprise customers in regulated industries with secure deployment options.

    The physics AI capability is part of a broader Mistral AI platform—alongside existing models, tools for building agentic workflows, and secure deployment options—forming what the company describes as a single stack spanning the engineering lifecycle.

    By the Numbers

    Key figures from the Mistral AI physics AI announcement and related sources:

    • 1.7B€ – Series C funding round led by ASML, at an €11.7B post-money valuation (source: Mistral AI)
    • 30+ – Number of researchers and engineers from Emmi AI joining Mistral (source: Mistral AI)
    • Seconds – Time for a single forward pass physics AI prediction on a single GPU (source: Mistral AI)
    • Hours to weeks – Typical time for traditional CFD or FEM simulation per design variant (source: Mistral AI)
    • Thousands – Number of design variants engineers can now explore instead of just a handful (source: Mistral AI)

    Frequently asked questions

    What is Mistral AI’s physics AI?

    Physics AI is a new class of AI models that learn from traditional physics solver outputs and predict physical system behavior directly from geometry and boundary conditions. It can map inputs to full physical fields in a single forward pass on a single GPU, reducing simulation time from hours or weeks to seconds.

    Why did Mistral AI acquire Emmi AI?

    Mistral AI acquired Emmi AI to strengthen its position as an AI transformation partner for industrial enterprises. Emmi AI brings expertise in Physics AI, large engineering models, and a team of 30+ researchers, enabling Mistral to offer real-time simulations and digital twins for sectors like aerospace, automotive, and semiconductors.

    Who are the initial partners for Mistral AI’s physics AI?

    Initial partners include ASML, Airbus, Safran, and Siemens Energy, focusing on high-stakes industrial applications such as chip manufacturing, aerospace, and energy systems.

    Will physics AI replace traditional simulation software?

    No, physics AI is not intended to replace first-principles solvers entirely. It targets the majority of design-loop iterations where speed is critical, while traditional solvers are reserved for verification, edge cases, and final validation.

    How does physics AI differ from large language models (LLMs)?

    Physics AI models use fundamentally different architectures, training objectives, and evaluation regimes compared to LLMs. They are not trained on simulation data as text but learn physics directly from solver outputs, mapping geometry and boundary conditions to physical fields.

    Sources

  • Website Investing: How to Recover Traffic

    Early in 2025 I purchased a website that provided a service to the Mexican market. Its revenue model was to allow the user to perform a certain task easily, then charge them for the end result (~$2 fee).

    The site was created in 2021 and in the past had generated $28,000 of revenue annually, most of which was profit. When I acquired it, it was on a steep decline in the search rankings, only making $3,600 annually and eventually hit a floor of around $1,200 revenue. I paid $5,000 for the site (with some other sites thrown in to sweeten the deal). For those interested I paid around 3x the annual revenue of all the sites I acquired.

    To recover rankings I decided to focus on one thing and one thing only – back links. For this I used a good but expensive provider. My goal was to spend $500 per month, netting between 3 and 5 backlinks pointing back to the site.

    Months 1 and 2

    In the first month there was zero change in site ranking. At the start of month 2 the rankings suddenly jumped from around position 9 or 10 to position 5 or 6. And how many extra site visitors do you think this resulted in?

    I was now receiving 4x the normal volume of Google Search clicks!

    Normally I would discount this jump as an anomaly. For example, perhaps some Mexican holiday had caused things to change BUT I have a control website.

    As part of the original deal another site had been thrown into the mix that ranked for pretty much all the same keywords. That second sites traffic and rankings did not change one bit during this period. In fact they declined.

    Therefore I can almost conclusively say that back linking was the reason for the jump in ranking.

    Change in impressions and clicks for the Mexican website (with paid back linking). From 10th May incoming clicks quadrupled
    Similar site ranking for the same search terms (no back linking). Only a mild decline in impressions and clicks.

    Interestingly I had only acquired 3 backlinks during that first month. However they were from well regarded sites with a domain rating of between 20 – 30 (the maximum rating being 100). Just 3 links had quadrupled inbound clicks!

    More importantly a move of 4 positions up the ranking resulted in 4x the traffic. On average, position 10 receives 1.5% of search clicks but position 5 receives 5.1% so the 4x in traffic tallies well with that general statistic.

    So where do we go from here? Obviously, position 1 is the goal and I think that is achievable, as my industry is low competition. Position 1 receives 40% of all search traffic so that is another 8x from where the site is now. That alone would restore annual revenue to $28,000.

    How Much Profit Does this Make?

    Purchase price: $5,000 (including some other sites but we’ll leave those out of this calculation)
    Back link cost: $3,000 to $6,000 (the latter if I need a full year of backlink building, which I’ll assume as worst case scenario)
    Cost of my time: $2,000 (2 days total at software engineer consultancy rates)

    Total acquisition and investment expenses: $13,000

    There are 2 scenarios to calculate return on investment:

    Scenario 1 – Keep the Website as a Cash Flowing Asset

    Annual income of $28,000 less back link expenses ($3,000) = Annual Profit $25,000. Factor in the purchase investment @ $13,000 and the annual return is 192% on original outlay.

    Where else could you get 192% return on your investments? Nowhere!

    Scenario 2 – Sell the Website

    In this case I would keep the site for 2 years to show a good track record of profitability to the potential buyer. Calculations as follows:

    Total profit (same as scenario 1) = $25,000 x 2 = $50,000
    Less purchase cost: ($7,000)
    Website value @3x annual profit: $75,000
    Less sales commissions (10%): ($7,500)

    Total income for 2 days of my time: $110,500.

    Yes that’s a nice number but this experiment needs room to run to see if it’s achievable. However if I scale back my expectations from position number 1 the numbers would change as follows:

    Profit According as a Function of Search Rank

    When selecting a target for acquisition and improvement I think the most important metric is to asses where you think you can get to in the search results. For example position 1 may be untenable due to a very well linked competitor – but is position 2 possible? Or 3?

    With my Mexican site, if I maxed out at position 2 then I would net $55,000 in case of a sale. For position 3 that number drops to $28,000. Even with the latter that’s still an earning of $14,000 per day of my time. In many countries that’s a full time salary!

    How to Scale?

    When I bought this site I promised myself I would NOT be doing any writing, blogs and other time consuming things. It was to be a pure back linking experiment, with almost zero of my time invested. Therefore, if I will not expand into other content areas this sites scalability will be limited once I rank at #1 for my particular search terms.

    Thus I will sell the site once I get close to that ranking goal.

    I’m already looking at acquisition of another website but at 10x the size (~$50,000 purchase price). The key is for that site is that it’s in a similar position with plenty of ranking upside. The upside, all else being equal, is somewhere between $140,000 and $1.1 million per day of my time.

    Now that’s food for thought (although I suspect this process will be less scalable the further up the ladder I go).

    I’m holding off for now though as I want to run the Mexican experiment for at least another 4 months to see how it actually goes! Look out for updates here!

  • How to Find a CTO for Your Startup

    So you have an idea and you probably think that 50% of the hard work is done. Now you just need someone to build it and millions will roll through the front door. You, sir, are one of many “Ideas Founders“.

    Ideas Founders believe in their idea so much that they think success is a certainty.

    Well, it’s bubble bursting time – very few companies get to that point. In fact, of VC funded companies in 2023 a whole 90% went bust. Your chance of not failing, if funded, is 10%. I’d even wager that a portion of those 10% barely make enough money to pay back the investors.

    And what if you’re not funded? Well the odds drop another 10 fold so we’re looking at 1%.

    • Yes, I know your idea is amazing.
    • Yes, I know you have a spreadsheet.
    • Yes, I know you’ve paid to have a kick ass design made.

    Your odds of success are still less than 1 in 20. I know this because Venture Capital makes all its returns from unicorn companies, which are 1 in a thousand. You don’t see the 999 that didn’t make it.

    But YOU ARE A GENIUS and still not dissuaded. You will manifest this product into the marketplace.

    The Product Creation Process

    Every business product starts with an idea. Did you know that ideas are the most abundant mineral on Planet Earth? Literally millions appear in peoples heads on a daily basis.

    However, your idea is unique, well researched and validated.

    So now you need to build that idea. You need something that us techies call a Minimum Viable Product (MVP). Then you can go out, test it, get feedback and iterate. This might take 4 months if the stars align, but more like 6-18 months.

    With total abandon you scrawl 10 lines of “specification” onto a napkin and request quotes from dev shops. Very quickly, though, you realise it’s expensive. You’ll need to part with at least 50k (but trust me you’ll always end up paying double that to get what you want).

    Problem is, you don’t have 50k, or if you do, you don’t really want to part with it. (But you still 100% believe in your idea).

    Of course this is not a problem as you have valuable stock to give away, right? That’s why you try to flag down a programmer whom you shall name CTO, offering him a huge chunk of your valuable company, maybe even 40%.

    Now you need only sit back and wait for him to build your masterpiece, with the occasional checkup call to see how your brilliant investment is doing.

    Show Me the Money

    Whilst your resident geek has been toiling away in his basement you’ve been doing a lot of work. Modelling financial projections, thinking about investment rounds, valuations and more. In fact your spreadsheets are a work of art. They are so good that you could sell them to buy a mansion and Rolls Royce with plenty of change left over for a private island. You are a genius.

    Then, an alarm goes off. Time to check in on your enslaved programming basement dweller Chief Technical Officer.

    Progress is going really well and the app looks good so you order it to be published. 1 week later you check downloads and sales figures.

    No downloads. No sales. No nothing.

    Hmmm, the product must be faulty. Time to have a heart to heart with your CTO.

    Despite “motivating” your CTO (another skill from your infinite stack) the masses still have not arrived…and there is still ZERO revenue. What gives?

    The End of Your Company

    After another 6 months of iteration there is still no revenue and you’re bored. It must be the technology that sucks. Maybe you should have had the Geek use React.js instead of Angular. Anyway, never mind, you’ve just noticed that a local coffee shop is doing amazingly well so you dream up a coffee subscription app that they could pay you for.

    This shiny new thing is what will get you that yacht.

    That old idea from a year ago simply didn’t have the right tech stack or CTO and that’s why it failed. Coffee is the new money maker in town.

    You gleefully part ways with that awful CTO and immediately begin interviewing for another one. This new one must be passionate about coffee, subscriptions and business processes. This time, it’s different.

    Why you Failed

    I hope that my sarcasm was strong enough for you to realise one thing:

    Sales is everything.

    No matter how good your CTO and product you must still put it in front of people and push for a sale. No sales means no revenue means no company.

    You may say this is obvious but many “Idea Founders” don’t realise it, wasting inordinate amounts of CTO time in return for stock that is worthless.

    Why You Won’t Get a CTO for Free

    The devils bargain is to hire a CTO for 40% of equity right? That way you get a competent employee for free, right?

    Actually, no.

    Any seasoned tech guy, be that lead dev or CTO is going to look at you very critically.

    • How many pre-sales do you have?
    • Did you create a no-code version of your app to see if the market wanted it?
    • Did you pay someone to create a basic MVP that you have signed letters of intent for?

    If the answer to these questions is no then he’s going to give you a hard pass. He wants to know what you bring to the table. And no, an idea is not worth anything.

    You may think that your offer of 40% equity will right this situation, and you’d be wrong. Let me show you why by asking a simple question:

    Where could I sell a quarter of my 40% stock, right now, to pay my bills?

    That’s right. Nowhere. Would you, the genius “Ideas Founder” even buy them? If my 40% is worth 400 million in the future then I’ll give you 10% now for a bargain price of 100 thousand! Let me guess, you won’t take that deal.

    AND YET, Ideas Founders expect us tech people to take worthless equity in return for a year of hard work building a product.

    Equity value is built, not dreamed into existence by your ideas.

    No-one serious is going to sign on to your company by the strength of your idea alone. 12 months of hard work in return for nothing – or I could build 25 of my own mini products on the web and float them to see what sticks. One of those could be worth 100k / year for 10 years. That’s a cool million in my pocket (for a few weeks of work).

    How does your 40% of nothing compare to that?

    Don’t believe me? Just have a look at Indie Hackers or Product Hunt to see all kinds of one man band success.

    So How do You Get a CTO?

    So far I have taken a big steaming dump on your dreams of getting a free engineer. Now let’s see how you can actually attract and keep one.

    1. An Engineer is not a Nerd, He is an Artist

    You may see Matrix code when you walk into an engineers office but he sees pure art. There’s something amazing about creating the perfect code that just gets us going. The ONLY way you get this out of someone is to not make them feel pressured.

    And can you guess how to get average output from an engineering rockstar?

    Easy. Simply treat him like an employee, one you don’t even pay. Order him around all the time and interrupt him continuously asking what he’s working on now.

    How far would Leonardo Da Vinci have gotten if his boss has been looking over his shoulder every 30 minutes?

    When you take on a CTO, he is your partner, and not your employee.

    Your CTO has a skillset that you do not possess so let him use it according to his best judgement. Never order him around. If you want something built then communicating that is fine (notice I said communicate and not order).

    Ultimately you’re taking him on to build the product and make sure it runs. Your technology views should be checked at his door or only brought up as though you were talking to your wife on Valentine’s day, and not your dog who won’t drop the ball.

    In short, he’s the f****** CTO so he decides technical things. Do not interfere and you’ll get the best from him.

    2. WTF do You Bring?

    Yes, you. And no an “idea” is not a thing. The 2 things you must bring are:

    1. Funding, or a solid route to funding (without sucking up CTO time before that)
    2. Sales ahead of time or gold star sales experience from your past

    If you only come with Option 1, then that is acceptable if you will pay for your CTO’s time, at least partially. If you also come with Option 2 then you are an A star candidate and CTO’s will throw themselves at you like you’re an A list celebrity.

    Personally I can count on one hand those I’ve met with Option 1 and am yet to meet someone who also has Option 2.

    You may look at this list and think you have neither but you’ll plough ahead anyway. Well, for that let me refer you to this Reddit thread (there are many more like it). Tech people are wise to your tricks. Offering us nothing for work doesn’t go so well when places like Facebook will pay you 150k starting salaries (plus stock).

    If you really believe in your idea then you can make an investor believe, and he will part with the cash you should pay the CTO to actually make your product.

    Who the F*** Are You to P*** on my Dreams?

    Hey, I get it. You’re angry reading this article. Your first reaction is to assassinate my character then I have no standing. So here’s my character for you:

    I’m just an average tech guy, building stuff I think will work. Every single day. Whatever I build I keep 100% equity in. I haven’t needed a job in 10 years, and probably never will. I’m not rich or poor but happy every single day because I love building – and I get to do it every day.

    Ps:

    If this article has offended you then please tell everyone on social media and link to it so they can be enraged too. All those free backlinks will sure teach me a lesson.

  • How to Become a Freelance Software Developer

    What Does a Freelance Software Developer Do?

    A freelance developer makes client websites, apps and software. He must also maintain those sites and applications over time as updates are always required and bugs appear from time to time.

    How Much Can a Freelance Software Developer Make?

    A typical freelance developer can expect to make between $40 – $250 per hour. Of course this depends on many factors such as what frameworks or languages you specialise in. It also depends on how good your networking skills are and how much real world freelancing experience you have.

    Now, if you’re based in Africa or Eastern Europe these hourly rates may look insane but they’re based on people hiring in the first world. If you are based in a poor country then you should be looking to find work outside of your borders!

    Why leave all us devs in the first world to take the cream? You can easily get some too!

    How to Learn Coding to Become a Freelance Developer

    First and foremost you need to love building things! Development is all about creating your clients (or your own) dream product. If you don’t like building then you won’t last the course. You should only be a freelancer in a subject area you love.

    The next thing you need to do is learn how to code with good architecture principles. What do I mean by this?

    Well there are many, many ways you can learn to code but they are not created equal! Many teachers will teach you very bad habits (me included about 10 years ago!).

    Those bad habits cause you to write bad code with many strange bugs, and this will ruin your developer reputation.

    If you’re just starting out then find a decent course provider that has a good reputation among senior developers. Ie, ask a senior dev, “If you had to learn from scratch, which course would you purchase?”.

    How to Find Clients as a Freelance Developer

    There are 2 places you can find clients:

    1. Your network
    2. Job sites

    The absolute best place to find paying clients is your network.

    Your network is basically those people who know you, whether personally or through other people. A network client is much more likely to hire you, but if you’re a beginner then this may not be feasible at first. Therefore, go to the second option….

    Your second option is to apply for one off jobs on sites such as Upwork. As you get started you can expect lower rates as these sites are very competitive. For example you may be competing with some guy in India offering $10 p/h and the client offering the job doesn’t know the difference in quality between him and you.

    How to Win Jobs on Freelance Developer Sites

    At this point everyone thinks that being a good developer will win the job. News flash: your clients have no idea what a good developer looks like, so they instead choose the developer based on 2 things. Understanding and rapport.

    Therefore you need to sharpen your listening, thinking and rapport skills.

    Here’s one little trick that will do all of that in one go, putting you ahead of everyone on these platforms:

    Offer a free consultation over Zoom so you can understand their needs.

    NO-ONE on these platforms does this and it blows my mind! Perhaps it’s because they’re a bunch of developers with zero people skills, I don’t know. This Zoom call approach works because it’s one of the principles of good sales – people buy from people they know.

    Once you talk to someone over Zoom, you’re now more familiar than that Indian applying with his generic email messages. In fact you’re even seen more favourably over a professional company!

    Yes, this will take a lot of your time (because you also need to prepare for Zoom calls) but just one good client is worth weeks of trawling through this process. Over time that client could be worth $100,000 so do the work now so that you may live like a king later.

    My final tip is to respond to clients email instantly. Business conversions go up by more than 10x when replies are within a minute of the enquiry being sent!

    How to Create a Freelance Developer Portfolio

    More often than not, your potential clients will ask to see previous work. If you’re a beginner then you have none! This is one reason why you must LOVE building – because your first portfolio will be things you’ve built for yourself.

    There is ZERO difference between your personal portfolio and a client based one. So take some pretty screenshots of your creations and get them on a website. Use WordPress or Wix or any other platform to show them off.

    Once you have a portfolio then copy it to social networks such as LinkedIn.

    Being on social networks (especially LinkedIn) helps to make you legitimate in the clients eyes. Remember, a client is always looking for any reason to not hire you and not being present on the internet is just plain weird these days!

    Do You Need an LLC or Company to Start Freelancing?

    I would say absolutely not. Having to register a company, get bank accounts etc will just slow you down and you may never start. instead of putting procrastination roadblocks in front of just get started on finding clients!

    After 3 or 4 clients you can start running your freelance jobs through a business, whatever structure the latter takes. This is a good idea to protect you from personal liability!

    Freelance Software Developer FAQs

    Here are some of the most common questions I get from beginners.

    How Hard is it to Become a Freelance Software Developer?

    It’s not hard but the most important thing is to be passionate about building! For example, I loved Lego as a kid so coding is perfect for me as it’s just digital Lego building!

    Once you start learning you should love coding – if you don’t then please don’t choose this as a career.

    Are Freelance Software Developers Wanted?

    The whole world is moving to digital and those things need to be created and maintained. This always requires a developer as the average worker cannot do it. Therefore demand for developers is going up all the time.

    What Skills Make You a Successful Freelance Software Developer?

    It goes without saying that you need to be able to code and have good software architecture skills. This keeps your code bug free and well organised. What most people don’t realise is that you need to have people skills too! Freelancing starts with marketing yourself and convincing a prospect that you’re the man for the job.

    Which Programming Languages are in Demand for Freelance Software Developers?

    There is no right answer to this question because is depends. However, you cannot go wrong with the classic and always in demand languages. These include JavaScriptPython, Java and PHP.

    With each of the above languages you should also learn an associated and popular framework. For example React or Angular with Javascript.

    Can a Freelance Software Developer Make 10K a Month?

    Absolutely you can! If you market yourself everyday by hopping onto Zoom calls you’ll eventually be the guy to go to for all your clients. The next time they have a big project (or their friend has) then you will the one stop shop.

    At this point you can start to increase your hourly rate for new clients and jobs. Just keep raising it until people start saying no – then you’ve found your ceiling. My rates are $125 p/h but I usually make $250 p/h as I have experience and can code much faster than many devs.

    For perspective $250 p/h is $10,000 after only 40 hours, that’s just 1 week of work!

    Fun fact: My record is $1,200 p/h as the work was much easier than I had anticipated!

    Finally, if you have any questions then leave a comment on one of my YouTube videos: https://www.youtube.com/@IAmDevtube

  • How to Start Freelancing

    About the author: I work as a software development freelancer. My minimum hourly rate is $125 but I usually double that to $250 as I get work done very, very fast. That’s the benefit of having skills and experience!

    This post is all about how you can get started with freelancing, and it’s not specific to developers. You can have any skill and still follow my process below.

    Is Freelancing Tough for Beginners?

    I hear this all the time and the answer is – absolutely not! Freelancing can be broken down into 2 simple activities:

    1. Having a skill that people need (this can be anything)
    2. Finding people who need your skill (who will also pay)

    Beginners often come to me saying their skills are really bad and they don’t know how to apply for freelance jobs. And you know what I tell them?

    Can you work a smartphone? Yes? Do you think there’s a 95 year old woman out there who would pay you $20 to show them how to use WhatsApp?

    Obviously the answer is yes! That old lady is going to think you’re a complete genius, even if you’re not that great on smartphones. And because she thinks that, and gets a result, she will happily pay you!

    So freelancing is for everyone, but especially for beginners as you put in the most effort, unlike us lazy veterans 🙂

    Which Freelancing is Best for Beginners?

    Well, I’m a software developer so naturally I say that’s the best. But I could be wrong. After all there are plenty of graphic designers that do great business, some even making over a million dollars a year!

    Therefore the type of freelancing you should do should be what you like doing.

    You should not look at how much your hourly rate will be and then choose a path. That is the way to demotivation as we rarely stick to paths we don’t have a passion for.

    • If you like making wooden benches then make them for clients.
    • If you like making apps then be a freelance app developer.
    • If you like designing things then be a graphic designer.

    If you have a choice between two things then you should pick the easiest one, assuming you want to start getting paying clients right now. If you have a bit of time then you can opt for the harder thing as that difficulty keeps competitors out and allows you to raise your rates.

    For example I’m a full stack developer – which means you bring your idea to me and I’ll do everything.

    This is great for a client, only having to manage one person instead of a team of 4. It’s also a lot cheaper even at my high rates (which is also a reason I can charge those high rates).

    However making full stack software is not easy and takes years to get good at it. So if you have the aptitude and the time then by all means go ahead.

    However if you don’t want to spend a lot of time or just hate learning to code then choose something else you’re good at and love!

    Do You Need an LLC to Freelance?

    I would say that you don’t need an LLC to start with, because the process will slow you down and kill your passion. You’re reading this article because you’re on the verge of starting so just get started NOW and operate under your own name.

    Take on a few small jobs just to test the waters. Then, if you enjoy freelancing you can always get an LLC later on.

    The one caveat I have is that you should always have a water tight contract that limits your liability. Working under your own name means that clients can sue you for any assets you own so a great contract is essential. You should definitely spend the money on getting a template contract from a good lawyer!

    You can also use that contract when you eventually open an LLC, so it has longevity.

    Spending money on a good lawyer may seem expensive today but if someone sues you it will be cheapest protection you ever bought!

    Put Together a Freelance Portfolio

    So you’ve decided to start but you have no client. What do you show potential clients as a catalog of previous work? Well that’s easy!

    Simply do some work for yourself and host that as the portfolio.

    • If you’re a graphic designer then make 10 logos / designs / prints.
    • If you’re a developer make 2 / 3 small apps and get them on the App Store.
    • If you’re a web designer then make 4 websites to show off your skills.

    Is this cheating? Not really if you ask me. A portfolio is there to show people what you can do, rather than showing them that you can attract clients.

    The beauty of this method is that you control what sort of work goes into your portfolio, so your potential client sees a unified interface. This makes it more likely they’ll sign with you because your portfolio looks very similar to what they need.

    Contrast that to a portfolio with multiple types of work which can look scattered and unfocussed. That’s not as attractive to a client.

    Finally, get that portfolio up on a webpage. If you have even minor technical skill then use WordPress, if not then use Wix or some other website builder. Your portfolio is no good if people can’t see it!

    How to Find Freelance Clients – Starting Out

    Now this is the potentially tricky bit, but only because there are so many options! If you’re a beginner then the best option is to start out on freelance job sites.

    Freelance job sites such as Upwork, Fiverr and Freelancer have thousands of listings. However, clients on there expect a lot of work for relatively little money, but that’s ok.

    As a beginner your goal is to get experience in applying for jobs and crafting your message. This will take time so be patient. You will be rejected dozens of times before you get your first job. I know I was! And don’t get dismayed at the low dollar amounts on offer.

    In fact my first client was on one of these sites and the first job was a grand total of $250. Let me tell you I worked like a slave for that $250!

    But guess what? When the next job for that client came up they only had eyes for me because I had proven myself. I quoted them $5,000 and they accepted within minutes!

    How to Find Freelance Clients – Level up

    Once you’ve had a few jobs from those job sites you will get a few follow on jobs from those same clients. My advice is to take them off the job sites and into direct contact with you. They should trust you by now so this won’t be an issue.

    Yes those job sites love to keep you working through them and continue taking 10-50% of everything you earn but don’t let them! Imagine working for an extra hour each day to put money in their pockets.

    Once your clients are truly yours you now have rate flexibility. Lookup the industry standard for your profession and start working your way there with each new job.

    Do not be afraid to massively raise your rates! People are looking for valuable freelancing skills and cheap prices imply that yours are not valuable!

    Yes, some clients will drop off but that’s fine. Trust me, you do not want to work for cheapskates and penny pinchers because they drain you of energy. You want to do good work for people who recognise and reward your value, because that’s a win-win situation.

    At this point you should have adequate experience in quoting, discussing and delivering work. Now you are ready for stage 2 of marketing, cold outreach:

    1. Get the contact details of local companies that could use your skills.
    2. Send them an email introducing you and your services. Outline the value they would receive if they worked with you!
    3. Follow up via email 2 weeks later or even call them.

    The above process should be continuous, with at least 5 companies that you cold email each week until your working time is full. At this point you can stop cold emailing as your network will continue to provide you with all the work you’ll ever need.

    How to Raise Freelance Hourly Rates

    If you follow my process your work schedule will eventually be full as you’ll have more clients than you know what to do with. Now is the time to start raising your rates, even more than int he previous step.

    Freelancers usually quake in fear at this point but fear not! I will give you a foolproof strategy for doing so.

    It all starts with treating your clients with respect. Be up front and tell them that you love working with them but your time is completely full. Any new work is going to suffer in quality so you’re going to start parting ways with some clients so this doesn’t happen.

    You’ve now just told your client there’s a chance they’ll be fired, which puts them in a mental state of wanting to do anything to stay on with you.

    No client wants to start from scratch and find a trustworthy freelancer all over again. Whenever I’ve done this I’ve always had emails asking that they stay on as the “chosen one”.

    In that same email tell them that you have to raising your rates by a certain amount to keep quality high. This is effective immediately for any new work coming in.

    However, your existing clients can have the current rates for the next 6 months. This gives them some warning but also makes them feel special for getting a 6 month discount on your new rates.

    This strategy has never, ever failed me but I’ve usually had 1 or 2 clients each time who say they don’t like the new rates – but they stayed on and paid them anyway!

    Freelancing – Avoid Bad Clients

    To end this long article allow me to show what a bad freelance client looks like. Here are some red flags in order of importance:

    1. Expects the world for little money (fire this client as soon as finances allow, they will drain your energy)
    2. Is rude and dismissive of you (definitely a firing offence)
    3. Micromanages you by requesting many tiny changes (these I move to a different pricing model consisting of a base project rate, then an hourly extras rate for other changes above a beyond the contract. This usually stops the micromanagement dead in its tracks. You can quote something nice and pricy for overage extras: $200 p/h with minimum of an hour usually does the trick.)
    4. Pays their bills late (not necessarily bad but you should draw a line in the sand where you stop doing work until invoices are made up to date. This works very well if their website or software breaks for example. You’d be amazed at how fast accounting get their finger out when the website stops bringing in revenue…)

    These traits are more guides than hard and fast rules so use your own judgement. If you see them appear time and again in the same client then it’s time to fire them or find another solution. On the other hand if these issues happen once or twice I would say that’s fine and a normal cost of doing business.

    Freelancing – What a Good Client Looks Like

    You will come across clients you love during your career. Unfortunately, at the outset you have no idea which ones are good and which are bad! It usually takes a few weeks to discover this (which is why I urge you to fire clients if need be).

    That said here are some traits of good clients I’ve seen over the years:

    1. They trust you to provide your expertise and don’t question everything you do (a few questions are fine though!)
    2. They usually pay their invoices on time.
    3. They’re happy to communicate with you throughout the job (this is important if you don’t want an unhappy customer at the end)
    4. They’re polite and easy to work with.

    Summary

    Freelancing is a very rewarding path to take, both financially and mentally. You get to meet people who are the movers and shakers and who knows, you might even pair up with one to make your own killer business!

    So, even if you’re a beginner, then I encourage you to absolutely go for it. Get your mini portfolio in order and start applying.

    Don’t overthink the process and just get started.

    To help you get started you can check out my Freelancer Flow Chart available at iamdev.net/free

  • createWriteStream async – Guide

    createWriteStream async – Guide

    When writing files to disk in node you have to be careful. Many times file writes require insertion of large chunks of data over a (relatively) long period of time. The key thing to avoid is opening the file multiple times which is resource intensive.

    It is far better to open the file once and hold that file handle in memory, ready to be used the next time. For that we use the createWriteStream async method.

    createWriteStream async in Node fs

    This method gives you ultimate control over file handling, which means more responsibility. Therefore you have to handle file opens, closes, errors and everything else that may go wrong.

    Let’s first look at the single line of code needed to create a createWriteStream:

    
    //cteate your sreite stream with optional options
    fs.createWriteStream (myFilePath, myOptions)
    
    ------------------------------------------
    myOptions can be any of the following:
      options <Object>
        encoding <string> Default: 'utf8' //file encoding
        
        autoClose <boolean> Default: true //autoclose after write? false = close it yourself
        
        emitClose <boolean> Default: true //emit event to notify file closed
    
        start <integer> //where should you insert the content?
        
        highWaterMark <number> Default: 16384 //how much data should this method gather before it's flushed to the file
        
        flush <boolean> // File descriptor flushed prior to closing. Default = false.
    

    Most of these will not be specified by you, just leave them as defaults. However, you may want to play with highWaterMark depending on your use case. That sets the buffer size and should be matched to the size / frequency of data streaming you have.

    NOTE: Always use a resource monitor such as atop or htop to know if you have issues!

    createWriteStream async Full Example

    Before we start, note that to use createWriteStream in its async promise based version (instead of callback versions) you use the fs module and not the fs.promises module! I know, I know it’s counterintuitive!

    The code below opens a write stream, writes something to a file on 2 separate calls then closes the file.

    const fs = require('fs'); //the main fs lib
    
    try { //always wrap in try catch as file writes can be error prone, especially on linux hosts...
    
      //create the writer object we can reuse
      let writer = await fs.createWriteStream('log-stream.txt', {
        encoding: 'utf8',
        highWaterMark: 16384,
        flags: 'a', //open and append (don't overwrite file)
      });
      
      //use the writer object
      await writer.write("Log 10: what happened in last 10s");
      await writer.write('\r'); //create a new line
      
      //sometime later
      await writer.write("Log 20: what happened in last 10s");
      
      //finally close the file to avoid memeroy leaks and file access issues!
      await writer.close()
      
    } catch (err) {
      console.error('Error occurred while writing file:', err);
    }

    Important notes: The above code shows a simplified step by step process to make it clear for you. To implement this in a real app, you would never write it this way, instead you’d create separate functions to handle file open, write and close – then call each function as you need them in your code.

    createWriteStream Events and Listeners

    FS gives us a lot of control over the file handling process, which means we can manually do everything ourselves. One of those options is choosing whether fs should close the file automatically or if we should listen to events and do it ourselves.

    If your file write is long in duration, over multiple chunks, then you can tell FS to leave the file open, saving the overhead of opening it over and over.

    This is perfect for server logs, for example. To do this we will listen to events called by createWriteStream. Here’s an example (code below):

    1. Open the file writer with createWriteStream
    2. Tell createWriteStream that we want to handle file closing ourselves (autoClose flag)
    3. Register event listeners for open, ready and close
    4. Write some text to a file
    5. Use the listeners and callbacks to decide when to perform next actions
    6. Close the writer once a write has been completed
    7. Remove all writer listeners to avoid memory leaks!

    Next, I have written the code in a step by step manner which is not realistic. You would separate this out in production to be called by the main program, as needed:

    Example createWriteStream async Code (Events)

    const fs = require('fs'); //the main fs lib
    
    try {
      let writer = await fs.createWriteStream("log-stream.txt", {
        encoding: "utf8",
        highWaterMark: 16384,
        autoClose: false,
        emitClose: true,
        flags: "a"
      })
    
      //add a listener with options such as open, close, ready
      await writer.addListener("open", async () => {
        console.log("Log file OPEN!")
      })
    
      await writer.addListener("ready", async () => {
        console.log("Log file READY!")
      })
    
      await writer.addListener("close", (fd) => {
        console.log("Log file CLOSED")
      })
    
      writer.write("hello world \r\n", async () => {
        await closeWriter(writer)
      })
    } catch (err) {
      console.error('Error occurred while writing file:', err)
    }
    
    async function closeWriter(writer) {
      await writer.close(async () => {
        await writer.removeAllListeners() // important to avoid memory leaks!
      })
    }
    

    Worth mentioning again: DO NOT forget to unsubscribe to your writer listeners on writer close or you’ll get memory leaks!

    Summary

    createWriteStream gives you power over all aspects of file writes but with great power comes great responsibility!

    As long as you handle events appropriately and monitor resource usage then you should be able to avoid pitfalls of this method and retain complete control over your file writes.

    If you want a deep dive into all aspects of Node FS then I have the Ultimate FS Node Guide here.

  • Is JavaScript Promise Sync or Async?

    TLDR; Any code in Javascript or Typescript that uses the word “promise” is asynchronous.

    What Does Async Mean?

    When coding asynchronously it means that your code is running on a different thread or CPU core than the main program that started the process. This leaves the main thread free to do important jobs like keeping the user interface responsive.

    How is Promise Related to Async or Callbacks?

    Async code used to use callbacks way back when. These are functions that get called when the long running task has been completed.

    Analogy: Imagine sending your little brother to the shops and telling him to call you when he gets there so you can give him your order. This is asynchronous as you can do another useful task whilst he’s driving there. The phone call (callback) tells you the driving task has ended and he’s ready for instruction *.

    * This is how all little brothers should behave, awaiting instruction from big bro 😉

    Back to code: This callback system is also known as a promise, as in: I promise to call you when my task is finished.

    Async and promises are the same thing.

    Async delivers exactly the same experience as a promise or callback, except it makes it MUCH more readable. Async is what we call syntactic sugar.

    //The following produce exactly the same result, both keeping long tasks off the main thread
    
    //PROMISE Version
    doSomething ((result) => {
      //CALLBACK code to run after doSomething has finished
      process(result)
    });
    
    //asynchronous syntactic sugar Version
    let result = await doSomething()
    process(result)
    

    Where Did Async Come From?

    Historically, as CPUs got more cores and threads we needed a way to make use of the parallel processing power. This is where the idea of offloading code to another thread came about.

    Async is short for asynchronous which means “happening at the same time as something else”. On a modern CPU that means you can have 32 things happening simultaneously (or even more with clever hyper threading technology!).

    Should Your Code be Async?

    Well, it depends. You shouldn’t always use async over sync or vide versa. There are specific situations where you would choose differently.

    Most beginners think that async keeps your UI thread free therefore all code should be asynchronous, but that is definitely not the case.

    See this post to find out why: is async better than sync?

  • Is Async Better than Sync in Javascript?

    Neither async nor sync are better in Javascript. Rather, they both have specific use cases. This post will show you the most common cases for each and the real world scenarios in which you would use them.

    TLDR; Use async code for all long running processes that take longer than 30 milliseconds. You can use synchronous code for everything else.

    What is Synchronous Code?

    This is code that executes in the order it is written. Take this example, where 3 tasks happen in order:

    Task sequence: A -> B -> C

    Therefore task B cannot start until A is finished and C cannot start until both A and B are finished. Synchronous code is normally where beginners to Javascript will start as it’s easy to write and understand.

    This is how you might write it in Javascript:

    let A = fetchData(myVariable)
    let B = fetchData(A)
    let C = fetchData(B)

    The Javascript interpreter reads your code line by line, executing everything from left to right and top to bottom. It does not move on until a line has finished executing.

    What is Asynchronous Code?

    Async code allows for tasks to happen at the same time. In our example tasks A, B and C could all happen in parallel, assuming they did not rely on each other for a result.

    Tasks happen at the same time: A & B & C

    However, if task B and C depend on A then you cannot run them all at the same time! In that case you might think you need to revert to synchronous code, but that’s not actually necessary. You should still use async code because you don’t want to tie up your main worker thread with long running tasks.

    This ability to use asynchronous code in a synchronous manner is where the confusion lies for most new coders.

    Keeping Your JS App Responsive

    Let’s say you have task C which relies on output from B, which relies on A. Clearly you would write these:

    Run tasks: A -> B -> C

    This looks exactly the same as our synchronous code example earlier. However, what if each task takes 2 seconds? That’s 6 seconds where your app is non-responsive, which is awful UX design. In fact Android will force close your app if you go over 15 seconds!

    This is because Javascript usually runs on the “UI or display Thread”. This is the CPU thread that conducts the orchestra of what’s happening in your code. It should be kept free of long running tasks, so it can concentrate on orchestration.

    Analogy: Imagine if an orchestra conductor had to conduct everyone, play the flute, guitar, piano and why not throw in sweeping the floor. Impossible right? And that’s why you keep long running tasks off your UI thread.

    If you’ve ever experienced an app crash (app not responding error) then it’s very likely that the developer wrote long running synchronous code on the UI thread!

    Async Code with Await / Promises

    Therefore, for long tasks, we have to take what should be straightforward synchronous code but use it in an asynchronous manner! This tells the system running your app to offload the task to a different CPU thread and please “callback” later with the answer.

    At some point in the future the answer comes back and you can use the result. This is what a callback looks like:

    getMyData((result) => {
      //this is the callback section
      process(result)
    })

    However callbacks can get very messy if you have a highly functional app. This is what happens if you have tasks A, B and C all waiting for each other:

    doSomething(a, (b) => {
      doSomething(b, (c) => {
        doSomething(c, (finalResult) => {
          ARE WE FINISHED YET??!?
        })
      })
    })

    The above code, ladies and gentlemen, is called callback hell. Imagine 10 processes with multiple steps between them and those nested callbacks can become insane sea monsters that will cause you to smash up your work cubicle!

    Callback hell is why the concept of async & await was invented.

    Javascript – Async and Await

    Async await is doing exactly the same thing as those callbacks earlier, except you write the whole callback in one line so it looks synchronous code, making for much easier reading.

    Let’s go back to the example with long running tasks A, B, C. Each must wait for the one before so it can now be written:

    let resultA = await fetchData(myVariable)
    let resultB = await fetchData(resultA)
    let resultC = await fetchData(resultB)

    The advantage to writing async code this way is that all that processing and waiting is now kept off the main UI thread. Therefore your app remains responsive. Coding like this is very, very important on the server side as you always want your server to be reachable.

    You can also click this if you want to know how async is related to promises.

    Is Async Code better than Sync?

    Yes and no. Async code should be used for long running or intensive tasks or ones where you do not know how long it will take. For small things such as storing variables or changing simple UI elements then you are perfectly fine with synchronous code.

    The above recommendation comes from understanding the frame rate of applications. Generally a user interface is considered smooth at 30 frames per second. Therefore you need to ensure that the UI thread is free every 1 second divided by 30 frames. That equates to a frame draw every 30 milliseconds.

    If your task goes over this 30ms threshold then make it async! An easy way to test this is to run your app for real, triggering multiple calls of the synchronous function that you’re concerned about. If the UI stays smooth then you’re good to go, subject to the below chapter on when to use async.

    You can also test how long certain functions take by opening the console on your browser (Chrome or Safari) and using the timelines functionality.

    When to Use Async Javascript

    As a rule of thumb you would always use async in the following situations:

    • Making a network call to a server or API
    • Processing something heavy (large data file or image)
    • Making a database call for reads or writes

    In fact, as you progress in your coding skill you’ll notice that more and more libraries use await async. Therefore it’s best if you get familiar with these concepts now, as it’s also encountered in many other programming languages and frameworks.

    Wrap Up

    Async code offloads work onto another CPU core / thread, keeping the main one free for user interactions or server responsiveness. You should always use async code where user experience and responsiveness matters, keeping those long running and unknown length tasks in the background.

    Finally, if you want a very deep dive on this subject then have a look at my ultimate guide on asynchronous vs synchronous in Javascript.