Live data from Hacker News

Ask HN: What change in your programming technique has been most transformative?

news.ycombinator.com

81–90 of 215 posts

Re: Ask HN: What change in your programming technique has been most transformative?

#81
Learning different programming paradigms. For example, logic programming with Prolog makes you think about solving certain problems quickly and efficiently in a declarative style. Strongly-typed functional languages like SML and OCaml make it easy to use types and pattern matching to reduce errors and shift some cognitive burden from yourself to the compiler. Lisps allow you to quickly prototype functions in the REPL and test them interactively, and thinking about code as data (homoiconicity) is a powerful concept.

In short, learning new programming paradigms completely changed my view of programming and these skills can translate over to more "mainstream" languages, so it is still a worthwhile effort.

Re: Ask HN: What change in your programming technique has been most transformative?

#82
It's okay to be messy.

Treat code mess with the same techniques you would treat RL mess. Sometimes you sweep it under the rug. You can toss it in a closet or attic. You can buy a shelf or box and toss everything in there.

You can clean it up seasonally, like set aside a sprint for it.

Some kinds of messes are hazardous and absolutely should not be tolerated - this is similar to leaving milk out or trash piling. Many people make this mistake of assuming that because some messes are very dangerous, all of it is too.

Most messes will slow you down, but cost more to clean up. Overall, I've seen documentation do more harm than help - it's often faster to interrupt a colleague doing something than for that colleague to spend weeks documenting and updating documentation on something that gets thrown away.

Some will take more time to fix later than now - this is what people mean by tech debt. But it's less common than it seems.

With a lot of mess piles, the important parts float to the top and the less important ones sink at the bottom. God classes are mess piles.

Once the mess becomes a burden, it's a good time to clean up.

You may need a few janitors and landscapers, especially for a large code base.

Some people place much higher priority on cleanliness than others. Be respectful of them but you don't have to be like them.

Re: Ask HN: What change in your programming technique has been most transformative?

#84
post #32

Functional Programming fundamentally changed the way that I solve problems. It also changed my expectations for how code should be designed. The concepts that influenced me the most were immutability and the power of mapping+filtering. Whenever I read a for/while loop now, I’ll attempt to convert it to the FP equivalent in my head so that I can understand it better.

map and filter are not concepts of FP - they are just syntactic sugar around for loops. fully evident if you check any native source code. many languages (such as go which I currently use) do not even have these functions but can apply FP. this is by design of simplicity and visibility: it does not get much easier to read than a simple for loop and know the exact iterations count at runtime.

One of the key principles of functional programming is, well, functions. A for loop isn't a function and isn't composable, map and filter are.

Re: Ask HN: What change in your programming technique has been most transformative?

#86
I used to just write code fast and forget about it, only slightly caring about the finished product. After having to build and support 2 fairly large applications(for use on a company intranet) I will fully plan, document and test my software. No more clever code, no more quick hacks. I also gave up on Javascript and node.js, and I mostly do c# now because of type safety.

Re: Ask HN: What change in your programming technique has been most transformative?

#88
post #82

It's okay to be messy. Treat code mess with the same techniques you would treat RL mess. Sometimes you sweep it under the rug. You can toss it in a closet or attic. You can buy a shelf or box and toss everything in there. You can clean it up seasonally, like set aside a sprint for it. Some kinds of messes are hazardous and absolutely should not be tolerated - this is similar to leaving milk out or trash piling. Many…

That's an excellent analogy.

Re: Ask HN: What change in your programming technique has been most transformative?

#89
post #82

It's okay to be messy. Treat code mess with the same techniques you would treat RL mess. Sometimes you sweep it under the rug. You can toss it in a closet or attic. You can buy a shelf or box and toss everything in there. You can clean it up seasonally, like set aside a sprint for it. Some kinds of messes are hazardous and absolutely should not be tolerated - this is similar to leaving milk out or trash piling. Many…

> Once the mess becomes a burden, it's a good time to clean up.

Definitely the way to go. It's not a problem until it's a problem.

Re: Ask HN: What change in your programming technique has been most transformative?

#90
Voraciously eliminating unnecessary whitespace, especially vertical whitespace, was a trick I learned early. Most monitors are wide, not tall. When you can see a whole function without scrolling it's much easier to understand. I'll collapse 'if' statements to a single line in most cases to make it readable left-right instead of up-down. 1TB bracketing is my default unless style guidelines prohibit it. End-of-line comments make it easier to associate functionality with comments and keep code tidy.
Post reply on HN