@vaporeon_ software eggineering poisons your brain
@wallhackio Are you referring to yourself or to me or to us all?
@vaporeon_ I'm referring to anyone who writes code for money instead of writing code for fun
@vaporeon_ this is not a slight on Holly. i hope that is clear. she does code golf so you know she actually likes coding for the hell of it
@wallhackio @vaporeon_ oh yeah all this goes out the window when you're golfing. sometimes it's fun to let loose and write some horseshit
@monorail @vaporeon_ my worst code practices occur when i hack a solution to a challenging data structures/algorithms problem
@wallhackio How can you have bad code practices when there's no such thing as good Java code, it's all terrible
@vaporeon_ I've done DS&A problems in JavaScript and written some nightmarish oneliners doing that
@wallhackio Need to see
@vaporeon_ look at this beauty:
var change = function(amount, coins) {
for (var i = 0, m = new Array(coins.length); i < coins.length; ++i) m[i] = new Array(amount + 1).fill(0), m[i][0] = 1;
for (var r = coins.length - 1; r >= 0; --r) for (var c = 1; c <= amount; ++c) for (x = r; x < coins.length; ++x) if (c - coins[x] >= 0) m[r][c] += m[x][c - coins[x]];
return m[0][amount];
};
@vaporeon_ @wallhackio this is javascript
Sorry, I didn't check which thread this was replying to, and thought this was an example of Go...
@vaporeon_ Array is the ordinary JavaScript array. using the constructor is abnormal but I know the exact size of the array so it is (probably) slightly more efficient to use the constructor so I can initialize it to an exact size.
in my experience var runs faster than let/const and its goofy scoping rules let me make the code more golfy. (I declare m
in the first for loop and the return statement uses m
! its terrible and i love it!!!!!!)
@wallhackio I'm sorry, I got confused and thought this was Go code
(Also, you should show me some Go code if you like it that much
Tell me of the cursed things that you can do in Go)
@vaporeon_ I don't know Go. I said I would probably like it, but that is a gut instinct based on, like, reading Wikipedia. I've never actually used it at all.
If I ever learn Go I will happily share horrendous code I make with it to
@wallhackio Oh, OK... Then maybe @aescling can show me the worst Go code she has ever written?
@vaporeon_ @wallhackio i haven’t written any go
@vaporeon_ I tried rewriting it with let and const and there was no real impact on the speed
@vaporeon_ it is 100x slower than the optimal solution and it is Worth It
@wallhackio What is an
Array
and why are we using that instead of just malloc-ing (or calloc-ing, if we want 0-initialization) some space? Also, what's up with thevar
, does it not have data-types like in C? Or isvar
like C++auto
?