-6 points

good. article upvoted. as are also good curly braces after if/else. too many times I’ve seen if/else without curly braces. why I should carefully read tens of loc, to find ifs? why can’t I find it at a glance, quickly scrolling the file? y do i have to read the line horizontally too to understand if the instruction is there or in the following line? why do I HAVE to add the curly braces to fix stuff? juniors get arty with this “feature” and unwrapping their logic becomes a real pain: but it looks so good!

permalink
report
reply
2 points
*

I agree with the need, but not your rationale, I’m in the “always curly braces” camp for two reasons:

  • when a second line gets added in a condition block, the braces might not get added, a bug.
  • one less decision to make while coding. Anything that removes trivial decision-making can speed up authoring and reading code.
permalink
report
parent
reply
1 point

well, in my rant, the bit about why do I have to add braces to fix stuff is very close to your first point, and the bit about reading while quickly scrolling to your second point, in which you say the right thing: not adding braces is something that one actively does. with no acceptable reason ever, imo.

permalink
report
parent
reply
1 point

Well, a couple things:

My points are related to provable advantages to doing it while writing code. They’re also not argumentative.

Your points are related to a personal preference of aesthetic while reading code. They are not provable advantages. They’re also quite “ranty,” which is rarely a persuasive way to convince someone of your position.

If you actually want to get people to change their habits around this, I think you’ll have better luck with my approach than ranting about why you don’t like how it looks.

permalink
report
parent
reply
6 points

I agree, typing is not a bottleneck, repeating yourself is. All that boilerplate code in the example, shouldn’t have to be written. It’s wasted time.

permalink
report
reply
1 point

The curse of OOP (java style…).

I mean why do you need to write getter and setter methods. I have wondered at the beginning of university 10 years ago, and am still wondering why you would need something like that…

permalink
report
parent
reply
1 point

I write Java for a living and the places I’ve worked have used Lombok to cut down on the boilerplate code

permalink
report
parent
reply
1 point

My condolences, haha (I’m honestly not a big Java lover ^^).

permalink
report
parent
reply
9 points

You let your ide generate simple getters and setters or utilize something that generates them during a compilation process.

Who ever writes them per hand needs to utilize their tooling better or needs better tooling.

permalink
report
parent
reply
3 points

Yeah but why do I have to use an IDE to generate getters and setters in the first place? It just adds up to more mental overhead, because my brain has to process this boilerplate somehow, even if my IDE can generate it (I know it’s simple code, but it’s even simpler to not have that boilerplate code at all).

permalink
report
parent
reply
12 points

Assuming this is C#, you could just make Reservation a record type, which can be defined with a one line primary constructor, is immutable and has value type equality. Second example is an insane amount of boilerplate.

permalink
report
reply
3 points

And you can use the with expression to create clones of the object with some properties modified.

permalink
report
parent
reply
42 points

8,000 characters in five hours is 1,600 characters per hour, or 27 characters per minute.

This is irrelevant. Typing when coding is not evenly spaced out over those 5 hours. It is sporadic with most of the time thinking or reading documentation or reading source code and trying to figure out what you want to type. No good conclusions can be drawn from this logic and makes that whole part of the argument irrelevant.

If I were typing that slowly I would quickly forget what the hell I was even trying to do in the first place. Which is the bigger part - when you do need to type you want to quickly get the ideas you have down as fast as you can think them. Going too slow can cause your mind to wander and that can really hamper your productivity.

There is also the cost of context switching. And it is a context switch to go from writing ideas down to making sure I have all the boiler plate and syntax correct. The less of the need for doing that the better IMO.

And TBH I don’t really understand the rest of their arguments. They introduce two bits of code, one very short simple class then one with lots of helper methods to set various things while creating a new object. And then concludes with a short paragraph on some real benefits without really explaining why. With the whole paragraph being more of an argument about immutable code being better rather than longer vs shorter code. Then follows up with an entire section on why his code increases maintenance as refactoring requires more points to update with his immutable code and thus prefers languages like F# where the immutable version is a one liner… Which defeats the whole argument that typing is not the bottleneck? I really don’t follow his logic here.

Apparently, it has to be explicitly stated: Programmer productivity has nothing to do with typing speed.

I feel they have completely failed to convince me of this fact. Despite me already thinking it is not one of the more important factors of productivity and there are better things to optimise around.

My opinion is that code length is not that important a factor, but you should not go hog while and write the longest things you can either. Every extra bit of code should add some value somewhere. Like taking his examples, spending a bit of time writing the immutable version here lets you reduce the amount you need to write when using that code. Which is a trade-off that can be worthwhile - increasing typing now for reducing typing later. But also the reduced typing makes the where the code is used easier to read and clearer as to what is happening, get a copy of the object with one field updated. That is a nice concept to have and read. Without the need to refer to all the fields every time you want a copy.

permalink
report
reply
12 points

Is it possible to be a productive programmer with slow typing speed? Yes. I have met some.

But…can fast typing speed be an advantage for most people? Yes!

Like you said, once you come up with an idea it can be a huge advantage to be able to type out that idea quickly to try it out before your mind wanders.

But also, I use typing for so many others things: writing Slack messages and emails. Writing responses to bug tickets. Writing new tickets. Documentation. Search queries.

The faster I type, the faster I can do those things. Also, the more I’m incentivized to do it. It’s no big deal to file a big report for something I discovered along the way because I can type it up in 30 seconds. Someone else who’s slow at typing might not bother because it’d take too long.

permalink
report
parent
reply
4 points

Also m, while I agree typing speed is an advantage, there’s nothing stoping you from laying out the whole program on paper or with psudo code and then filling it in which can reduce the need to keep it all in your head

permalink
report
parent
reply
3 points

IMO trying to write everything out in psudo code first is way slower. You are writing things out twice and you are not able to run things quickly. You just have to hope you got things right on the first pass and cannot quickly adjust things when you don’t.

I prefer constant feedback from my editor, compiler and test framework to write things quickly and make sure I am not doing something that is fundamentally flawed. There is nothing worst than writing a whole program without running it only to run it and realise nothing is working how you thought it should.

permalink
report
parent
reply

I type slowly so i just write my ideas down on paper first

permalink
report
parent
reply
11 points

Wrong. Yes, typing speed does not matter when counting up lines of code. Code programmers however are not just code monkeys. They write documentation and comments, communicate with peers and potentially users, take notes on their own thoght processes when pondering on the best solutions for hard problems, etc. On all of these point and many more, typing speed matters. People who can type and type fast(-ish) communicate more expressively, document more comprehensively, make less mistakes when spelling, etc.

So yes, typing skill matters.

permalink
report
reply
11 points

People who can type and type fast(-ish) communicate more expressively, document more comprehensively, make less mistakes when spelling, etc.

That’s just pure conjecture on your part though

permalink
report
parent
reply
-4 points

Sure, if you regard scientific studies and statistics as conjecture, then your right, it’s pure conjecture.

permalink
report
parent
reply
8 points

Happy to be proved wrong if you cite your scientific sources though.

permalink
report
parent
reply
4 points

People who can type and type fast(-ish) … make less mistakes when spelling, etc.

I wish.

-Guy who types over 100WPM but still makes a lot of spelling mistakes.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.7K

    Posts

  • 28K

    Comments