1. 2

    When this topic is brought up, I feel like there are many that will comment about how JSON is faster. Or it’s only slow on first load and browser without reloads and caches everything else is faster, or another excuse I’ve read is that if done right… you wouldn’t have these SPA issues people bring up (the links, tabs, back/forward buttons, refreshes, etc…), but isn’t that basically requiring the SPA developers to re-develop all the very basic, and free, functionality that a browser comes with? Also, it’s so easy for some tech-head to just right click, inspect, and get around your lame client side validations or some other wacky issue that prevents me from clicking submit. (Which I have actually ended up having to do on some sites.)

    My favorite way I do a web page, app, whatever the politically correct contemporary term is that won’t offend the full time front end react and vue developers or bootcampers or javascripters, is to just not develop it initialially with javascript mostly. Then go through it, polish perhaps, and do my extra fancy CSS stuff, then go over it again, with a second layer, and throw in my JavaScript (sprinkles?) and make it a little richer. Basically where a page is like an app or in Rails world speak I just render partials on the server and use JavaScript responses and do a simple document.querySelector(‘element’).innerHTML = mypartial.

    Am I old and moldy?

    1. 1

      The problem comes down to complexity: you’re adding another deployment configuration that your app has to support. If you develop a web app that’s supposed to be progressively enhanced, then you have to test it with JavaScript on and with it off. Just as an example: lobste.rs mostly uses server-side template rendering, but some of the buttons don’t work without JavaScript. If @pushcx wanted to fix that, he’d probably end up implementing that functionality twice. You’re basically doubling your test workload.

      Worse than that, though, is that the common approaches to enhancement are straight-up spaghetti code. This post gives a pretty good example. And even if you’re smart enough not to take the naive jQuery approach to implement something as complicated as a speculatively-updated Like Button flow, the code that you write when you support JS both on and off has more essential complexity than when you only support the case where JS is on. You’re basically doubling the amount of code paths.

      This is why Slimvoice, the JavaScript-free frontend that this lobsters story is about, uses all those complex CSS hacks. Discourse solved the conundrum by making almost all of the functionality JS-only. Slimvoice solved the conundrum by making almost all of the functionality JS-free.

      I’m actually working on yet-another-Reddit-clone and trying to figure a good way out of this mess myself. I don’t want to write a SPA; I’ve seen the code under the hood at Discourse, and reimplementing a quarter of the browser’s native functionality myself like they have to do is way too much work. I don’t want buttons that mysteriously do nothing when you go noscript, either. And I certainly don’t want to reload the entire page whenever you star something. You’re not old and moldy, but nothing in your post actually spells out how I can eat my cake without losing it.

      1. 1

        I don’t have an answer to everything, but I the following stuck out to me:

        The problem comes down to complexity: you’re adding another deployment configuration that your app has to support. If you develop a web app that’s supposed to be progressively enhanced, then you have to test it with JavaScript on and with it off.

        I don’t think this is particularly true. If someone’s prepared to ignore all non-JS-users by considering a JS-only site, then I don’t see why they’d have a problem ignoring all non-JS-users of a progressively-enhanced page. It’s similar to a stance like “we don’t support IE”: that doesn’t mean we should sniff user agents and avoid sending pages to IE users. Rather, we send them the page and let them muddle through on their own.

        I’ve always done progressive enhancement as a Web dev (I think it’s sloppy and unprofessional not to do so). It’s not hard; it just requires an appropriate mindset and a little experience, then if something works with tables+images+CSS+JS, etc. turned on then it will usually degrade gracefully (similar to the “if it compiles, it works” mantra of statically typed languages: it’s not true in general, we there are approaches we can follow which make it usually true).

        I don’t want buttons that mysteriously do nothing when you go noscript, either.

        This is a pet peeve of mine: don’t send across HTML that, on its own, is misleading. This applies to buttons which aren’t attached to forms or hyperlinks, but also things like “spinner” gifs which give the impression that something is loading. Anything which requires JS to work, should be added to the page with JS. It’s not hard.

        I certainly don’t want to reload the entire page whenever you star something.

        That’s the point of progressive enhancement: to enhance, not to avoid implementing. If you want to use JS to implement in-place updates then go ahead. All progressive enhancement would ask is that either you send across a crude non-JS implementation by default (like “reload the entire page”) and “enhance” it with JS on page load; or don’t include that functionality at all in the page that’s sent across. Just don’t send links/buttons that don’t do anything.

        Note that this doesn’t require much effort at all. In particular, something like replacing form POSTs with in-place updates doesn’t need two separate implementations of the feature: it’s the sort of thing that JS libraries make trivial, so we just need to e.g. put a certain class and/or data attribute on the button and run a generic function on page load to find/replace any occurrences.

        In fact I would claim that “broken button” implementations are probably more complicated and highly coupled than doing it properly, since they spread the “single implementation” across HTML and JS. In contrast the “two implementations” version would have a self-contained HTML version and a self-contained JS version (which may or may not be a single JS library call). The “don’t send any HTML, add it during page load” version is a single self-contained JS implementation.

        1. 1

          I don’t think this is particularly true. If someone’s prepared to ignore all non-JS-users by considering a JS-only site, then I don’t see why they’d have a problem ignoring all non-JS-users of a progressively-enhanced page.

          If you’re not actually supporting it, you’re doing graceful degradation at best.

          Note that this doesn’t require much effort at all. In particular, something like replacing form POSTs with in-place updates doesn’t need two separate implementations of the feature: it’s the sort of thing that JS libraries make trivial, so we just need to e.g. put a certain class and/or data attribute on the button and run a generic function on page load to find/replace any occurrences.

          I mean, obviously the database code doesn’t need to be written twice. But most of the frontend logic does.

          Going with the like button example, your template pretty much has to do this kind of thing for the non-JS users.

          <button class="star-button {{#if this.starred_by_current_user}}star-button-active{{else}}star-button-inactive{{/if}}">{{#if this.starred_by_current_user}}Remove Star{{else}}Add Star{{/if}}</button>
          

          Obviously, I’m using CSS to replace the button text with an image, and after clicking the button, the server sends out a redirect back to the article you voted on.

          Now I’m going to deploy a piece of JavaScript, and annotate the button with some info to handle it.

          <button class="star-button {{#if this.starred_by_current_user}}star-button-active{{else}}star-button-inactive{{/if}}" data-in-place-button="1" data-in-place-button-toggle-classes="star-button-active star-button-inactive">{{#if this.starred_by_current_user}}Remove Star{{else}}Add Star{{/if}}</button>
          

          I’m using an imaginary library that takes care of toggling classes, so if star-button-active is present then it gets replaced with star-button-inactive, and vice-versa. It also invokes the form action through XHR, silently swallowing any non-error response that the server gives.

          This naive implementation has a severe accessibility bug: the script doesn’t do anything with the alt text. I can fix that bug individually, but you can see how this is a violation of DRY: when the server renders a component that the client then has to update, the two have to be kept in sync. Also, since most users don’t see the server-generated redirect (since the JavaScript hides it), that code can easily bitrot.

          As you mentioned, you could just not offer voting for anyone without JavaScript. But if you actually do want to support users with JavaScript disabled, not allowing them to decide which content gets promoted on a news aggregator seems like you’re giving them the middle finger.

    1. 2

      One of the best Vim (Neovim) articles I’ve read. I’ve begrudgingly stuck with Vim (8) instead of Neovim. Is there really a case to switch to Neovim? Right now, I messed up my .vimrc one day. Didn’t want to fix it (or lazy or sick of configuring and tweaking), so here I am using Sublime for the last few months instead. I tried VS Code, but only use it at home on my side projects in Go, Python, and/or C#. I use Sublime right now for everything else at work (Ruby/Rails since VS Code Ruby/Rails is something to be desired).

      I’d really like to just get back into and use Vim (or Neovim) since it’s reliable. Available. Free. Open source. And does only what I need. Nothing more.

      1. 1

        Try https://github.com/lunixbochs/actualvim , which is a Sublime plugin that embeds Neovim quite seamlessly.

      1. 2

        Princeton Coursera Algorithms Part 1.

        Finishing the first homework and starting week 2.

        That first assignment caught me off guard. Sheesh. I thought I was good at this stuff, but now I’m not so sure. The second week looks more familiar though. I hope that goes a little smoother.

        1. 1

          How’s it compare to spacemacs with mypy, pylint and pyfmt enabled? My only complaint with spacemacs is the completion tends to be a bit janky.

          1. 2

            Check out the LSP layer included on develop branch: https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/lsp

            1. 1

              Thanks.

          1. 2

            Working on small side project website, mobile, and JSON API and setting up switching over to Doom Emacs config from Spacemacs.

            Aside, if you use Spacemacs, does it eat up your power/battery? I am on macOS and Energy usage in Activity Monitor nearly sits steady 150+ during usage and I get maybe 75 minutes of battery on a 2017 MacBook Pro.

            1. 1

              What on earth is it doing to draw power like that? I run Emacs (just my own config) and even with rcirc and mastodon.el filling a few buffers it typically sits at zero CPU usage.

              1. 1

                You can try doing profiling on your Emacs to see what plugin can take so much CPU: https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html . Usually, it’s not Emacs itself, it’s a plugin that might misbehave.

              1. 15

                As a junior developer doing my best to learn as much as I can, both technically and in terms of engineering maturity, I’d love to hear what some of the veterans here have found useful in their own careers for getting the most out of their jobs, projects, and time.

                Anything from specific techniques as in this post to general mindset and approach would be most welcome.

                1. 33

                  Several essentials have made a disproportionate benefit on my career. In no order:

                  • find a job with lots of flexibility and challenging work
                  • find a job where your coworkers continuously improve themselves as much (or more) than you
                  • start writing a monthly blog of things you learn and have strong opinions on
                  • learn to be political (it’ll help you stay with good challenging work). Being political isn’t slimy, it is wise. Be confident in this.
                  • read programming books/blogs and develop a strong philosophy
                  • start a habit of programming to learn for 15 minutes a day, every day
                  • come to terms with the fact that you will see a diminishing return on new programing skills, and an increasing return on “doing the correct/fastest thing” skills. (e.g. knowing what to work on, knowing what corners to cut, knowing how to communicate with business people so you only solve their problems and not just chase their imagined solutions, etc). Lean into this, and practice this skill as often as you can.

                  These have had an immense effect on my abilities. They’ve helped me navigate away from burnout and cultivated a strong intrinsic motivation that has lasted over ten years.

                  1. 5

                    Thank you for these suggestions!

                    Would you mind expanding on the ‘be political’ point? Do you mean to be involved in the ‘organizational politics’ where you work? Or in terms of advocating for your own advancement, ensuring that you properly get credit for what you work on, etc?

                    1. 13

                      Being political is all about everything that happens outside the editor. Working with people, “managing up”, figuring out the “real requirements’, those are all political.

                      Being political is always ensuring you do one-on-ones, because employees who do them are more likely to get higher raises. It’s understanding that marketing is often reality, and you are your only marketing department.

                      This doesn’t mean put anyone else down, but be your best you, and make sure decision makers know it.

                      1. 12

                        Basically, politics means having visibility in the company and making sure you’re managing your reputation and image.

                        A few more random bits:

                    2. 1

                      start a habit of programming to learn for 15 minutes a day, every day

                      Can you give an example? So many days I sit down after work or before in front of my computer. I want to do something, but my mind is like, “What should I program right now?”

                      As you can probably guess nothing gets programmed. Sigh. I’m hopeless.

                      1. 1

                        Having a plan before you sit down is crucial. If you sit and putter, you’ll not actually improve, you’ll do what’s easy.

                        I love courses and books. I also love picking a topic to research and writing about it.

                        Some of my favorite courses:

                        1. 1

                          I’ve actually started SICP and even bought the hard copy a couple weeks ago. I’ve read the first chapter and started the problems. I’m on 1.11 at the moment. I also started the Stanford 193P course as something a bit easier and “fun” to keep variety.

                    3. 14

                      One thing that I’ve applied in my career is that saying, “never be the smartest person in the room.” When things get too easy/routine, I try to switch roles. I’ve been lucky enough to work at a small company that grew very big, so I had the opportunity to work on a variety of things; backend services, desktop clients, mobile clients, embedded libraries. I was very scared every time I asked, because I felt like I was in over my head. I guess change is always a bit scary. But every time, it put some fun back into my job, and I learned a lot from working with people with entirely different skill sets and expertise.

                      1. 11

                        I don’t have much experience either but to me the best choice that I felt in the last year was stop worrying about how good a programmer I was and focus on how to enjoy life.

                        We have one life don’t let anxieties come into play, even if you intellectually think working more should help you.

                        1. 8

                          This isn’t exactly what you’re asking for, but, something to consider. Someone who knows how to code reasonably well and something else are more valuable than someone who just codes. You become less interchangeable, and therefore less replaceable. There’s tons of work that people who purely code don’t want to do, but find very valuable. For me, that’s documentation. I got my current job because people love having docs, but hate writing docs. I’ve never found myself without multiple options every time I’ve ever looked for work. I know someone else who did this, but it was “be fluent In Japanese.” Japanese companies love people who are bilingual with English. It made his resume stand out.

                          1. 1

                            . I got my current job because people love having docs, but hate writing docs.

                            Your greatest skill in my eyes is how you interact with people online as a community lead. You have a great style for it. Docs are certainly important, too. I’d have guessed they hired you for the first set of skills rather than docs, though. So, that’s a surprise for me. Did you use one to pivot into the other or what?

                            1. 7

                              Thanks. It’s been a long road; I used to be a pretty major asshole to be honest.

                              My job description is 100% docs. The community stuff is just a thing I do. It’s not a part of my deliverables at all. I’ve just been commenting on the internet for a very long time; I had a five digit slashdot ID, etc etc. Writing comments on tech-oriented forums is just a part of who I am at this point.

                              1. 2

                                Wow. Double unexpected. Thanks for the details. :)

                          2. 7

                            Four things:

                            1. People will remember you for your big projects (whether successful or not) as well as tiny projects that scratch an itch. Make room for the tiny fixes that are bothering everyone; the resulting lift in mood will energize the whole team. I once had a very senior engineer tell me my entire business trip to Paris was worth it because I made a one-line git fix to a CI system that was bothering the team out there. A cron job I wrote in an afternoon at an internship ended up dwarfing my ‘real’ project in terms of usefulness to the company and won me extra contract work after the internship ended.

                            2. Pay attention to the people who are effective at ‘leaving their work at work.’ The people best able to handle the persistent, creeping stress of knowledge work are the ones who transform as soon as the workday is done. It’s helpful to see this in person, especially seeing a deeply frustrated person stand up and cheerfully go “okay! That’ll have to wait for tomorrow.” Trust that your subconscious will take care of any lingering hard problems, and learn to be okay leaving a work in progress to enjoy yourself.

                            3. Having a variety of backgrounds is extremely useful for an engineering team. I studied electrical engineering in college and the resulting knowledge of probability and signal processing helped me in environments where the rest of the team had a more traditional CS background. This applies to backgrounds in fields outside engineering as well: art, history, literature, etc will give you different perspectives and abilities that you can use to your advantage. I once saw a presentation about using art critique principles to guide your code reviews. Inspiration can come from anywhere; the more viewpoints you have in your toolbelt the better.

                            4. Learn about the concept of the ‘asshole filter’ (safe for work). In a nutshell, if you give people who violate your boundaries special treatment (e.g. a coworker who texts you on your vacation to fix a noncritical problem gets their problem fixed) then you are training people to violate your boundaries. You need to make sure that people who do things ‘the right way’ (in this case, waiting for when you get back or finding someone else to fix it) get priority, so that over time people you train people to respect you and your boundaries.

                            1. 3

                              I once saw a presentation about using art critique principles to guide your code reviews. Inspiration can come from anywhere; the more viewpoints you have in your toolbelt the better.

                              The methodology from that talk is here: http://codecrit.com/methodology.html

                              I would change “If the code doesn’t work, we shouldn’t be reviewing it”. There is a place for code review of not-done work, of the form “this is the direction I’m starting to go in…what do you think”. This can save a lot of wasted effort.

                            2. 3

                              The biggest mistake I see junior (and senior) developers make is key mashing. Slow down, understand a problem, untangle the dependent systems, and don’t just guess at what the problem is. Read the code, understand it. Read the code of the underlying systems that you’re interacting with, and understand it. Only then, make an attempt at fixing the bug.

                              Stabs in the dark are easy. They may even work around problems. But clean, correct, and easy to understand fixes require understanding.

                              1. 3

                                Another thing that helps is the willingness to dig into something you’re obsessed with even if it is deemed not super important by everyone around you. eg. if you find a library / language / project you find fun and seem to get obsessed with, that’s great, keep going at it and don’t let the existential “should i be here” or other “is everyone around me doing this too / recommending this” questions slow you down. You’ll probably get on some interesting adventures.

                                1. 3

                                  Never pass up a chance to be social with your team/other coworkers. Those relationships you build can benefit you as much as your work output.

                                  (This doesn’t mean you compromise your values in any way, of course. But the social element is vitally important!)

                                1. 2

                                  Not sure how I feel about it as I would rather be reading some fantasy fiction like Harry Potter or Snow Crash and working on a fun side project, but working my way through some old CS books and problems. I feel soft and like my CS skills and train of thought has started to atrophy. Building data structures from scratch, doing a few problems from the chapters. It can get a tad boring sometimes and requires a bit of discipline.

                                  No, I’m embarrassed to say I have never read Snow Crash. I’m on book 4 of Harry Potter and enjoy them so far, fun and easy to read and get into. Mom and brother turned me on to them. Next on deck is finishing The Chronicles of Narnia books. I’m book 2, in love with these as well. As I always have, I’m re-reading Foxtrot comics as I feel. Been doing this since about 12 years old. Never gets old for me.

                                  Maybe a similar themed thread about what we are watching? Or what we are playing? Working my way through Final Fantasy III (VI in North America).

                                  1. 3

                                    I had a Thinkpad 600e in college with FreeBSD on it (Window Maker was my jam). I miss it, dearly. Some day, I hope to go back to a similar setup. If that’s OpenBSD, I’m fine with that too.

                                    I’ve held off on a new Thinkpad for various reasons: 1. Work provided me a laptop, so I use that mostly (MacBook Pro) with no reason for buying another machine, 2. Getting myself to spend the money is always a struggle for me, and 3. Waiting to see what this Retro Thinkpad ends up being like.

                                    The X1 with OLED display is extremely tempting though.

                                    1. 16

                                      Headphones, turn notifications off, find a way to politely let people know when you don’t want to be disturbed (wearing headphones is a good start), and the rest is self-discipline. Most of my distractions come from me goofing off online, not due to my open office.

                                      1. 6

                                        I find having headphones a pain after few hours. Having no noise in your ears all day is difficult to have if you’re in an open-space at work, but really great and so refreshing!

                                        1. 4

                                          I just wear the head phones and have no music running. The headphones dull the noise around + also indicating that I’m not interested in random conversations. I use the Bose QC 35.

                                          1. 2

                                            This used to happen to me. Then I bought better headphones. Problem was solved. I’ve spent thousands of dollars (USD) on headphones to find what I felt were the best for me and my use. I used to be a headphone snob. I am now content and liquidated my collection keeping only 3: Denon D7000, Sony MDR-1R (I imported from Japan), and the Beoplay H6 (2nd generation)

                                            Those are my 3 favorites and I’m honestly perfectly content with and have been for at least a couple years. I can go all day with any of the 3 on my head and not really notice.

                                            Marco’s review of the Beoplay H6 2nd Generation: https://marco.org/2016/03/02/beoplay-h6-v2-review

                                            1. 1

                                              Thank you very much for the advices! I was looking for a new pair of headphones and this is really great!

                                              Regarding my comment, having a good pair of headphones doesn’t change the fact that a marble silence is sometimes nice to work with. I like being in the openspace when I need to collaborate and I don’t mind some noise, when I need to focus deeply, remote at home provides the silence that helps me focus.

                                              1. 1

                                                I used to work in a really noisy open space.

                                                I’d wear soft earplugs (from a construction safety supplier) under big over-ear headphones.

                                                Frequently I wouldn’t even have any music playing - the headphones hid the plugs, and provided a socially acceptable explanation for not hearing the people around me.

                                        1. 13

                                          On a tangential remark, I’ve been enjoying going to a coffee shop after work and learning and re-learning mathematics and physics in order to continually stretch my mental capacity. It helps tremendously with stress management at work itself. I feel more capable of taking on enormous, difficult tasks at work because of the challenges I face in remembering how to tackle these math and physics problems that I faced in college. I started doing this about a month ago with a geometry textbook. I’m up to Precalculus now, about 10% of the way through the Precalculus textbook by Stewart. I’m planning on going through Calculus and onto Classical Mechanics, followed by Electrodynamics and Quantum Mechanics. (I really do want a good challenge!)

                                          1. 7

                                            You’re lucky. After eight hours of programming/meetings the last thing I want to do is program or do match. After some dinner with my SO, I go straight to reading (never tech stuff) or video games.

                                            1. 1

                                              For QM I would recommend Shankar just for the intro section on linear algebra, although most people seem to prefer Griffith’s for the actual QM stuff.

                                              If you like type theory or algebra (the grown-up kind), I can PM you a link to an early WIP draft textbook from one of my former professors that covers classical mechanics in an exceptionally mathematically rigorous way, with full coverage of the algebraic properties of different physical quantities and systems. It’s actually for a simulation course, but it’s better for learning classical physics than any physics course I’ve taken.

                                              1. 2

                                                Thank you for the suggestion! I have read in a few places that reading multiple QM books is common. This is the list of books that I’ve got lined up.

                                                • Precalculus: Mathematics for Calculus, 6th Edition by James Stewart et al. (Amazon link)
                                                • Calculus: Early Transcendentals by James Stewart (Amazon link)
                                                • Classical Mechanics by John R Taylor (Amazon link)
                                                • Introduction to Electrodynamics by David J. Griffiths (Amazon link)
                                                • Mathematical Methods in the Physical Sciences by Mary L. Boas (Amazon link)
                                                • Introduction to Quantum Mechanics (2nd Edition) by David J. Griffiths (Amazon link)

                                                My biggest concern about this list is which order to read the last four items in. I was thinking of starting in the order listed, but I may end up having to jump around given that there is likely going to be overlap between them.

                                                1. 3

                                                  For what it’s worth, during my undergraduate studies in Physics, Mathematical Methods in the Physical Sciences and Classical Mechanics were taught for two semesters each, in parallel. In the second semester, alongside the two, we’ve had an Introduction to Quantum Mechanics course (mostly as a conceptual and historical introduction, no very advanced stuff). Finally, Electrodynamics and a “full” QM course followed the year after.

                                                  (There were a lot of other courses in parallel, but these are the relevant ones to your listing. You might want to add a Statistical Physics / Thermodynamics textbook in there for good measure. :))

                                                  Try checking out the curriculum of a few undergrad courses on universities near you to get a feeling for a reasonable order of reading.

                                                  1. 1

                                                    Muchas gracias, amigo. That is a most excellent idea.

                                              2. 1

                                                What do you mean when you say go through? Do you do all the problems? How do you decide on problems to work if you do any at all?

                                                1. 1

                                                  Anything that is difficult to grasp I’ll review it by going through enough problems until I feel comfortable with the topic.

                                                  I’ll go back and review fundamentals to re-enforce dependent material, too.

                                              1. 2

                                                I graduated at a big school in CS. However, I do want to go back to get my major/grad school in CS some day. I don’t have a reason other than I like to learn. I love the academic environment and my dream job is to be a professor or teach. My brother did this, but in statistics and just finished his PhD in December 2016.