Swizec Teller - a geek with a hatswizec.com

    Livecoding 52: First impressions of Vue

    This is a Livecoding Recap – an almost-weekly post about interesting things discovered while livecoding. Usually shorter than 500 words. Often with pictures. Livecoding happens almost every Sunday at 2pm PDT on multiple channels. You should subscribe to My Youtube channel to catch me live.

    This weekend I set out to build an idea @TheKitze had on Twitter. An app that gives perspective to your life. Oh, you don't have time to read a book? Well, you spent 5 hours on Twitter yesterday. Are you sure?

    https://twitter.com/thekitze/status/931948509472927744

    For the MVP, I envisioned a form where you fill out what you don't have time or money for, ask for some perspective, and the webapp delivers. It doesn't deliver yet because I decided to build it in Vue.

    You can see some of my initial struggles with Vue in the video above. In a few bullet points 👇

    1. Vue's onboarding experience feels like a warm hug. You're immediately showered in community support, example projects, and helpful resources.
    2. vue-cli is more accommodating to different preferences than create-react-app. It asks questions and tries to configure itself for a good experience.
    3. The default ESLint config that comes with vue-cli is woefully incompatible with my Prettier config. That was painful. I wish it came with a .prettierrc file so it would configure my autoformatter to the settings it expects.
    4. Throwing linting errors instead of warnings by default feels a little forceful. I had to re-make my project from scratch without ESLint.
    5. Choosing the right VSCode extension to get Vue support… well, there are a lot of them. I ended up going with the Vue Extension Pack. I don't know everything that it did for me, but I'm sure I'll need it eventually.
    6. Out-of-the-box support for end-to-end testing with Nightwatch is 👌
    7. The Vue coding experience itself… I think I need to give it more time.

    Vue feels like a bastard child between React 13 and Angular 1. I love that it uses and promotes components. That's how it should be. I like that it tries to conform to the web-components standard. It's a good standard, and this will help it come about quicker.

    I hate the Angular 1 style v-if and v-for stuff where you shove a bunch of complex logic into your templates. I know this is hypocritical coming from the React world where we shove our templates into JavaScript, but somehow that feels more elegant.

    Yes, the React approach does lead to some horrendous code when people put too much logic into their JSX.

    Yes, it's all about programmer discipline to avoid mixing presentation with logic too much.

    And yet, I still feel like it's more elegant to treat HTML as a first-class citizen in your JavaScript than to treat JavaScript as a 2nd class citizen in your HTML.

    With React, it feels like my JavaScript directly manipulates what's on the screen. I'm building a UI and have direct control of what's being shown to the user. I can assign pieces of the UI to different variables, treat them as Just Data™, and generally have fun and feel in control.

    Vue, on the other hand, enforces an artificial separation of concerns that I don't think is useful. I'm still building a UI and manipulating what's on the screen, but it feels removed. Like trying to tie a knot with 10 foot tweezers instead of your fingers.

    With React, I can reach in and get dirty. With Vue, my dandy little hands never touch anything real.

    That's what it feels like anyway. shrug

    And the syntax for building components feels strange too. Very React 13 where we didn't have proper JavaScript class or function support yet.

    export default {
    name: "MyComponent"
    data() {
    return {
    data1: "",
    data2: ""
    }
    },
    methods: {
    doThing() {
    },
    onClick() {
    }
    },
    components: {
    ChildComponent
    AnotherChild
    }
    }

    o.O

    That, to me, looks weird. Where are all the advances we've made in JavaScript over the past few years?

    Why am I defining child components with an object, internal state, called data, with a function, and a list of methods as what looks almost like a class but isn't quite? Feels weird.

    I like the React approach where you have a JavaScript class. Its methods are its methods, its props can be state, there's a .state variable which is the proper connected state, and children are automagically defined by being nested in the component. You know, just like in normal HTML.

    Wouldn't it be weird if in HTML you had to declare all the children you're going to use in a certain element?

    So far I am more weirded out than impressed. Perhaps with time Vue will grow on me.

    🤓

    Did you enjoy this article?

    Published on November 20th, 2017 in Livecoding, Technical,

    Learned something new?
    Want to become an expert?

    Here's how it works 👇

    Leave your email and I'll send you thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

    Join Swizec's Newsletter

    And get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.

    "Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"

    ~ Ashish Kumar

    Join 15,161+ engineers just like you already growing their careers with my emails, workshops, books, and courses.

    ⭐️⭐️⭐️⭐️✨
    4.5 stars average rating

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Want to brush up on modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️