Live data from Hacker News

3 lines of code shouldn't take all day

devtails.xyz

81–90 of 213 posts

Re: 3 lines of code shouldn't take all day

#81

This is probably a controversial opinion, but I think that working in an environment where time-to-iterate is high is actually very beneficial for improving your skills. It's one of those things that may feel overly burdensome in the short term, but is better in the long term. I say this as someone who taught programming with beginners, and observed what many of them will do when given an IDE, which at the scale of t…

My longest compile times were when I was doing iOS development (native), and even then I couldn't kick the habit of relying on quickly looking at my changes and using logging for debugging. Not the best.

On the other hand, at least it's a motivator to look at the build pipeline every once in a while and see if there's anything that can be improved.

That said, working in a typed language with good IDE support definitely helps build up the confidence that things will work as intended before you hit compile.

Re: 3 lines of code shouldn't take all day

#82
post #26

Agree with this so much. One of the main things that I try to do is ensure that the turn around time between testing and writing code is as short as possible. As an example I inherited a codebase about 2 years ago that would take 15 minutes to run the test suite. It was painful. It was just long enough that it would waste an entire day just trying to implement a simple feature. The project was behind schedule and no…

Another much under-utilized way to speed up test suites: delete tests

Can one configure tests to run in “full”, “actual” and “scope:” modes?

Re: 3 lines of code shouldn't take all day

#84

This is probably a controversial opinion, but I think that working in an environment where time-to-iterate is high is actually very beneficial for improving your skills. It's one of those things that may feel overly burdensome in the short term, but is better in the long term. I say this as someone who taught programming with beginners, and observed what many of them will do when given an IDE, which at the scale of t…

I see it like driving stick vs. automatic.

Sure, with stick you become aware of how the car works, the engine, torque and clutch, and you get more control. This might be good for learning.

But automatic lets you pay more attention to the road ahead, whether you are a new or experienced driver.

Re: 3 lines of code shouldn't take all day

#85
post #45

This guy is young and probably not educated in modern dev. I refuse C++ jobs when I ask how they do unit test and they reply it's too hard in C++, and take Java jobs because there the first question THEY ask is HOW I do unit test, what I think of coverage metrics (hints: they don't matter much) and how I propose to enforce ALWAYS unit testing important code. In this blog post the guy took 3 job change to DISCOVER uni…

I think the main issue about automatted unit/integration testing is not the language, but the area you are writing code in. Yes, C++ not having good unit test support hurts. But it hugely depends on the problem domain and whether the outputs are machine verifiable, and the inputs are easy to simulate.

It's hard to do unit tests in a large part of the area of gamedev. How do you ensure that a picture is rendered correctly? You can take a screenshot and compare it to a stored one. But then what happens if you do artistic changes that you want to do? You have to update the stored screenshots of the testsuite. Who will review that the changes all made sense? And more importantly, there might be slight differences in the output of GPUs, depending on driver versions, model, etc.

So let's say you have a bug in your game where if you walk through a level in a specific direction, the game crashes. The error is easy to check for: just make sure that there is no crash. But how do you create a reproduction of the bug? You could record controller inputs and play them back. Then a different department changes something how quickly players move and increase their walking speed by 10%. Suddenly your player walks into a wall and the test is basically broken.

Compare this to a CRUD app where you have well defined operations and their impact is well described.

That being said, even in gamedev there are areas that are well testable. You can do a unit test of the low level networking layer by trying to make a server and a client, dropping some packets, then looking if the packets still arrived because the networking layer sent them again.

Re: 3 lines of code shouldn't take all day

#86
Regarding the "testbeds". I recently built this for an (iOS) application and it helps SO MUCH. Each module in the app has its own local target (the testbed) with a menu which lets you open the module for a given scenario. A scenario is a combination of local JSON for endpoints, device fakes (think fingerprint enabled/disabled) and module-specific configurations. The ability to near instantly get to a specific functionality with the same network requests makes everything super simple. I run the UI tests on these targets as well, and they are near perfectly non-flaky.

The best part is when I receive a new bug report from QA, since they include the network logs I usually just need to create a new scenario, register the JSON and fix the reproduced issue.

Re: 3 lines of code shouldn't take all day

#87

This is probably a controversial opinion, but I think that working in an environment where time-to-iterate is high is actually very beneficial for improving your skills. It's one of those things that may feel overly burdensome in the short term, but is better in the long term. I say this as someone who taught programming with beginners, and observed what many of them will do when given an IDE, which at the scale of t…

In the same vein: I'm very used to "printf debugging". When I use a language where it's harder to do that, I feel like I improve as a programmer because I spend more time reasoning and thinking about my code instead of directly trying to fix the problem I have right now.

As a more general thing: you can learn a lot by removing tools that you usually use from your toolbox. For example, going from a managed language to manual memory management. Going from an IDE to shell commands. Removing tools like language servers. Each time I did one of those things, I learned a lot. However, there are lots of things to learn and I don't know if this was the "most effective use of my time".

Another example of hard to balance learning: I'm currently working for a company. Should I focus my learning on their business and our codebase, or on general technology? General technology is a transferrable skill, and I'm scared of being "trapped" in a company if I focus on their specific parts too much. But on the other hand, companies want to recruit efficient people, and I think focusing on the business and our codebase would make me more efficient.

I'm a junior engineer, so maybe that's due to a lack of experience. If anyone has insights to share about that, I'd love to hear them.

Re: 3 lines of code shouldn't take all day

#88

This is probably a controversial opinion, but I think that working in an environment where time-to-iterate is high is actually very beneficial for improving your skills. It's one of those things that may feel overly burdensome in the short term, but is better in the long term. I say this as someone who taught programming with beginners, and observed what many of them will do when given an IDE, which at the scale of t…

I've observed "trial and error coding" many times in my life. This isn't caused by a short feedback loop at all. The people who work like this will work like this with a long feedback loop too, they will just take a lot longer to do anything. These people are simply incompetent programmers.

Re: 3 lines of code shouldn't take all day

#89
post #39

Going from "manual testing" to automated testing is the biggest jump. Unfortunately, lots of folks (both developers and managers) fall into the trap of thinking they will "use up" their development time on automated tests, and not really thinking how much time they're already wasting just to do (incomprehensive and hand-wavy) manual tests each time. And while this strategy might work for the folks who actually wrote…

This is where I stop understanding modern ui frameworks. Instead of making an ui inner machinery (controllers) as a set of modules which could in theory run even in a non-browser environment, they pile up everything together into dom/etc. UI could be just a thin layer over usually testable ui-controllers, whose methods could be called by either controls or offline test suites (as in most desktop frameworks). But nope, they do mountains of “smart” views and test them instead as a whole.

…I just googled for “React TDD” and the top no-money result suggests finding divs in containers and spying on dom changes. It’s like testing your cli app by hooking into tty driver’s section in /dev/mem.

Re: 3 lines of code shouldn't take all day

#90

Earlier quoted context omitted.

How much time did removing docker shave off?

Docker helped me to significantly increase unit test speed on one project. Each test was recreating database, run dozens of DDL scripts over and over (to ensure clean environment). I reimplemented in in a way that DDL scripts were run once, then container with database was commited to an image and that image was re-used for every test. Also multiple containers were run at once, so tests could be run simultaneously. D…

[deleted]
Post reply on HN