Live data from Hacker News

Small programming tricks

will-keleher.com

71–80 of 193 posts

Re: Small programming tricks

#71

Earlier quoted context omitted.

In what context can you avoid branches?

Maybe something (contrived) like this providing no-op defaults? total = calculateOrderTotal(user.order); if (user.isPremiumMember) { total = total * 0.9; // 10% discount versus total = calculateOrderTotal(user.order); discount = calculateDiscount(user); // Returns 0.9 or 1.0 total = total * discount;

Didn't you just shift the branch to the calculateDiscount() function?

Re: Small programming tricks

#72

Earlier quoted context omitted.

Weird personal attack, thanks. What I'm saying is I am not a jerk and actually do care about my coworkers, however I also don't want a bunch of noise in a chat app I have to use to do my job.

You can mute the channel. Why would you want your teammates to communicate less ?

I think that it would be unwise to mute #engineering or whatever the main eng channel is

>I shared a trick on slack every day with the engineering team

Re: Small programming tricks

#74
post #2

This reminded me to ask: To what extent are people still coding by hand these days? In my profession (academia), literally no one codes anymore. On one hand, it sucks because the joy and fun of programming has been replaced by constant agent orchestration tasks, but on the other hand, it's hard to go back to the way things were before because the productivity gain is so good. I remember learning a lot of these progra…

I write code by hand because LLMs do not provide any significant productivity gains. They turn out code fast, but then I have to review it to make sure the code is correct. That takes me about as long as it would to write the code myself in the first place, so I continue to write the code myself.

Re: Small programming tricks

#75
post #34

Earlier quoted context omitted.

s/seen as// Annoyance is a clue; not about them, but about you.

Weird personal attack, thanks. What I'm saying is I am not a jerk and actually do care about my coworkers, however I also don't want a bunch of noise in a chat app I have to use to do my job.

The post writer is also a person that you attacked for no reason even tho he's not your coworker.

Re: Small programming tricks

#76
post #62

I can recommend https://www.oreilly.com/library/view/unix-power-tools/059600... The "Unix Power Tools" book is an excellent source for Unix and shell usage tricks

After 24 years and it is still useful. I would add Sed and Awk books as well.

Re: Small programming tricks

#77
The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something.

Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.

Re: Small programming tricks

#78
post #34

Earlier quoted context omitted.

s/seen as// Annoyance is a clue; not about them, but about you.

Weird personal attack, thanks. What I'm saying is I am not a jerk and actually do care about my coworkers, however I also don't want a bunch of noise in a chat app I have to use to do my job.

I thought it sounded like a nice gesture of trying to be helpful and making a small connection with their coworkers. One message a day is hardly "a bunch of noise". Even though you say you wouldn't have said anything at the company, you said something here, and that has a similar chilling effect on other people who might have been inspired by the OP to share their tips and tricks with their coworkers.

Sorry for the "personal attack" but my point stands, you may not think of yourself as a jerk, but I saw your comment and thought "this guy imagining himself being annoyed at a coworker for a daily message with a helpful tip might be more of a jerk than he realizes". As a jerk myself I judged myself qualified to make that assessment and commented accordingly.

Re: Small programming tricks

#79
post #5

Earlier quoted context omitted.

Also in academia but I'm old and my real work is done withy students. I'm coding by hand much less than I used to (boo) but solving more problems with code myself than I used to (yay). Having an llm do things turns out to be similar to having a student do them but with fast turnaround and it's fine to have them work on your home automation system. ;)

Another academic. LLMs are great for opening searches. I state what I would like to get into and let it get some initial paper recommendations. It seems to solves a hard problem: discoverability. Maybe I'm just getting subjected to more subtle bias but it is extremely easy and fast now to get a nice selection of relevant literature to review. Analysis and any artifacts are all handcrafted by me. I mean, that is the w…

[dead]
Post reply on HN