70 points signa11 1 hour ago 51 comments
behnamoh 58 minutes ago | parent
I remember learning a lot of these programming tricks over the years. They would give me happiness: learning something new about nvim, or some new shortcut in the Fish shell, or a new Vim macro, or the difference between 1 bracket or 2 brackets in Bash scripts, etc. But now it seems like all of them are irrelevant, and I wanted to see how others think about the situation.
dgacmu 51 minutes ago | parent
huurtehoog 32 minutes ago | parent
Analysis and any artifacts are all handcrafted by me. I mean that is the work. I have never seen papers or code as an outcome. What I want is to learn and enable other to learn. That I can only get from doing the work myself.
SoftTalker 48 minutes ago | parent
I'm fortunate I guess in that most of my work tasks have very loosely defined deadlines, if any at all.
catlifeonmars 32 minutes ago | parent
I don’t mean this to brag, mostly to point out that in my line of work, actually writing the code is not the biggest bottleneck.
For context I work on greenfield network security appliances
skydhash 32 minutes ago | parent
bradly 31 minutes ago | parent
acedTrex 26 minutes ago | parent
So i still get daily use out of these tricks.
Are there people that are literally ONLY interacting with a computer via an LLM? thats crazy if its true
spprashant 13 minutes ago | parent
VCFundedGenYer 53 minutes ago | parent
Natashash23 52 minutes ago | parent
winternewt 42 minutes ago | parent
Here's one that I think more people should know: avoid branches. If I can do the same thing without an if statement and even a logical expression, the code typically both becomes easier to understand for people and easier to run for the CPU.
cachvico 25 minutes ago | parent
craftkiller 10 minutes ago | parent
corps_and_code 8 minutes ago | parent
if (thingThatIsTrue):
// a bunch of logic here...
else: // different logic here...
they mean:if (thingThatIsTrue):
return doThisWhenTrue()
return dothisWhenFalse()Just a simple example. I'm not sure if this is what you consider "obfuscating" the branches. Logically the same, but a bit more linear to understand?
Edit: I am bad at formatting comments here.
cestith 5 minutes ago | parent
It's not applicable to every situation, but one way to do this is some very basic fuzzy logic. You do a little math and then either choose a single branch at the end, or sometimes avoid a branch altogether. https://www.geeksforgeeks.org/artificial-intelligence/fuzzy-...
Another way to avoid some branches is to have specialized routines, maybe with multiple dispatch, rather than more general methods with a bunch of checks within them for slightly different situations.
A classic performance hack for critical sections is loop unrolling.
bryanrasmussen 5 minutes ago | parent
if Val === "A" then Do funcA() else if Val === "B" then
and so forth for lots of values, or using a switch statement or similar branching instead of
Object functions = { "A": funcA() {does what funcA does}, "B": funcB() {does what funcB does} etc. etc.
}
runnableFunction = functions[val]; runnableFunction();
Actually writing it I remember now someone who did this, a junior who had to update a validation function for XML invoices based on their root namespaces, which there could be a large number of these, and so she wrote out
switch namespace == "somenamespace" { validatingscheme = "someschema"; doPreliminaryFunctionToDetermineifshouldvalidate(); }
I can't remember all the details as this was almost 20 years ago, however while it was true that one branched on the schema, it made much more sense to look up what one was supposed to do based on the rule for branching and then just execute that one action rather than writing a bunch of branching logic.
So to make it more concrete: Once branching rules becomes sufficiently complex prefer query for what you should do rather than branching
on edit: note again, not real code, but should be understandable and translatable into real code to understand what is being said easily enough.
reaperducer 23 minutes ago | parent
Or stupid, like all those vloggers posting "ZOMG! Go all in with these secret hidden weird trick iPhone life hacks to level up!" that are just regurgitating what's in the manual.
As we used to say, RTFM: https://support.apple.com/en-us/docs/iphone
cestith 19 minutes ago | parent
metabagel 8 minutes ago | parent
lscharen 4 minutes ago | parent
total = calculateOrderTotal(user.order);
if (user.isPremiumMember) {
total = total * 0.9; // 10% discount
versus total = calculateOrderTotal(user.order);
let discount = calculateDiscount(user); // Returns 0.9 or 1.0
total = total * discount;overflowy 41 minutes ago | parent
jawns 38 minutes ago | parent
popzxc 27 minutes ago | parent
IMHO the value of these nuggets is that you understand what you're doing and why; opening yourself to large amounts of non-default behavior likely will end up in a less than pleasant setup.
Not taking into account that different users might disagree on what is convenient and what is not, which is basically the point of making things configurable.
farrellm23 26 minutes ago | parent
kccqzy 22 minutes ago | parent
NegativeLatency 37 minutes ago | parent
I would find that annoying, however to not be seen as a jerk I wouldn't say anything.
blooalien 28 minutes ago | parent
CableNinja 21 minutes ago | parent
I frequently do the same, but not everyday; only when i think its something actually useful/helpful beyond the everyday crap. Most recently, we have had a huge push to use ai (just like everywhere else), ive been getting pretty creative with it, and at this point have a well polished setup that i can give a shitty sentence on a problem, not only does it understand the task, but theres a full ticket->branch->work->pr review->ready comment flow that it uses. My team also uses ai but they havent quite wrapped their head on ways to really work with it. I have built and shared a number of helpful things with the team to try and help them grow. One such thing was a doc i had my ai instance write, based on how ive been using my setup. This alone has started to get the rest of the team up to where i am.
My team doesnt share the same types of things i do, but they still share helpful things.
Call it what you will; I think if youre not helping your team grow by providing insights and helpful things, then youre not the kind of person i want to work with.
NegativeLatency 11 minutes ago | parent
One is actually helping and the other is making yourself more visible to mgmt for promotions.
saulpw 17 minutes ago | parent
Annoyance is a clue; not about them, but about you.
NegativeLatency 10 minutes ago | parent
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.
adzm 35 minutes ago | parent
;with [[[]][[[](_)as(select 1 union select 0),[[]][]][](_)as(select 1 from [[[]][[[] []]]][]]],[[[]][[[] _),[]][]][[](_)as(select 1 from [[]][]][] []]]][]]],[[]][]][] _),[[[[[]][](_)as(select 1 from []][]][[] []]]][]]],[]][]][[] _),[[[]][]]](_)as(select 1 from [[[[[]][] []]]][]]],[[[[[]][] _)select _ from(select row_number()over (order by _)from [[[]][]]])[[[]][[[](_);
/s
williamcotton 35 minutes ago | parent
In the macOS terminal you can...
Ctrl + Option + -
...and it'll undo your typing.Dunno about other OS keys!
AJRF 29 minutes ago | parent
aDyslecticCrow 27 minutes ago | parent
Record a debugging terminal session including output to a file. Its pretty great.
elendilm 26 minutes ago | parent
For me, I personally use nothing fancy other than normal KDE Kate for backend development.
Function and variable names are chosen after putting a lot of thought into it which also includes being amenable to grep and sed.
ahmedhossamdev 24 minutes ago | parent
cachvico 24 minutes ago | parent
CableNinja 16 minutes ago | parent
FlyingSnake 12 minutes ago | parent
monideas 19 minutes ago | parent
wiredfool 17 minutes ago | parent
okinternets 16 minutes ago | parent
IsTom 16 minutes ago | parent
kccqzy 14 minutes ago | parent
teekert 8 minutes ago | parent
jonstaab 7 minutes ago | parent