|
snypes
|
# ? Feb 7, 2014 05:35 |
|
|
# ? May 28, 2024 16:11 |
wesley snypes posted:snypes Banned.
|
|
# ? Feb 7, 2014 06:05 |
|
javascript is seriously awfulcode:
code:
ok, now run them in jsfiddle or something. notice that the first result is 10, what the gently caress while the last result is 0, as a sane person would expect. but the only difference between the second program and the first is that instead of simply assigning to a[i] an anonymous function that returns i, there is the extra step of calling this new function f(i), which returns... an anonymous function that returns i. shouldn't these programs have identical results? especially since the formal name for what i did in the second program is "eta expansion", which is supposed to be equivalent to the original? i say that a sane person would expect 0 because the anonymous function assigned to a[i] is supposed to capture the current state of its environment like a proper closure, and at that time the value of i was 0. then a[1]() should return 1, etc. what happens is, the function does capture its environment, in which i is a mutable variable (a pointer to something), whose state can and does later change out from under us after the other iterations of the loop. ok, that's awful, but then why does the second program do the right thing? because the process of passing i into the parameter x of f makes javascript copy the current value of i into x, and because there is a different x for each invocation of f, mutation is no longer an issue
|
# ? Feb 7, 2014 06:54 |
|
does anyone know a good book on algorithms/algorithmics or whatever its called im trying to become a less bad programmer
|
# ? Feb 7, 2014 11:15 |
|
lots of languages work like this. the only exceptions i can think of are when variables are immutable, or when you explicitly choose whether to copy or reference if you want per-closure state, declare your variable inside the for scope
|
# ? Feb 7, 2014 12:10 |
|
javascript only gets blamed for that behaviour because it's the first place most people run into itPython code:
Python code:
qntm fucked around with this message at 12:50 on Feb 7, 2014 |
# ? Feb 7, 2014 12:31 |
|
this is what a sane language looks likecode:
|
# ? Feb 7, 2014 13:03 |
|
Awia posted:does anyone know a good book on algorithms/algorithmics or whatever its called I liked The Algorithm Design Manual by Steven Skiena (PDF). It reads easily and will be a good intro to basic algorithms in many categories, and can be used as a stepping stone if you need to dig in deeper later on.
|
# ? Feb 7, 2014 13:50 |
|
thank you very much it doesn't load at work but i'll take a look later
|
# ? Feb 7, 2014 14:19 |
|
that's because js is a poo poo language where you implicitly take references to local mutable values and the only way to construct copies is through function scoping like a goddamn dog.
|
# ? Feb 7, 2014 17:09 |
|
JewKiller 3000 posted:javascript is seriously awful The actual issue here is js' variable hoisting. All variables are only scoped to the nearest function. an equivalent program would be code:
however, the language is still bad.
|
# ? Feb 7, 2014 17:24 |
|
Zaxxon posted:The actual issue here is js' variable hoisting. All variables are only scoped to the nearest function. an equivalent program would be Hoisting doesn't explain this at all. Even if JavaScript had block scope and i only existed for the interior of the loop, you would expect to see the same behaviour. You can see that i is being modified ("i++") for each successive iteration, not created anew. All the closures therefore refer to the same i, which, at the end of the loop, has value 10.
|
# ? Feb 7, 2014 18:14 |
|
is there any better python ocr library than pytesser? it's suiting my needs atm and is super simple but i may as well use something better if it exists
|
# ? Feb 7, 2014 20:50 |
|
okay I've learned how to implement the following data structures and algos today: - Linked List/Double Linked List/Stack/Queue - Binary Tree - Directed/Undirected Graphs - Merge Sort/Quicksort/Bubblesort. Binary Tree Search. Breadth/Width searches on graphs/trees What am I missing? I can point at things and say "yeah this is quadratic time and this is log time and this is linear" but I can't really get into more detail than that. I haven't done hashmaps. I can only fit so much more in my head in the next couple days. I really want to nail this interview so I can go from a hobbiest terrible programmer to an official terrible programmer.
|
# ? Feb 9, 2014 23:22 |
|
this is already as much as you will ever be asked by a sane interviewer with your big 'O' basics knocked out, i would concentrate on language features/wrinkles in whatever you are putting on your resume
|
# ? Feb 9, 2014 23:33 |
|
USSMICHELLEBACHMAN posted:okay I've learned how to implement the following data structures and algos today: answering your question directly without commentin' on the worth of learnin these things vs other skills, off the top of my head the next ones to look at (in priority order) would be
coffeetable fucked around with this message at 00:05 on Feb 10, 2014 |
# ? Feb 10, 2014 00:01 |
|
coffeetable posted:answering your question directly without commentin' on the worth of learnin these things vs other skills, off the top of my head the next ones to look at (in priority order) would be these are all useful and important if you are going to be implementing data structures, but are they important to interview for a boring business applications job? p.s. i have no idea what a k-d tree is and i am not ashamed to admit that
|
# ? Feb 10, 2014 00:04 |
|
Notorious b.s.d. posted:these are all useful and important if you are going to be implementing data structures, but are they important to interview for a boring business applications job? It's a fancy way to measure your Blops score. True gamers unite.
|
# ? Feb 10, 2014 00:05 |
|
learn a hashmap/table/whatever so you can say "well if i just used a hashmap intsead it'd be faster but then i'd use more space i dunno man what do you want from me let me suck your dick ill do it no dont act gay about it just let me do it come on man slap that dick in my hand yeah feels good dont it poo poo look at it squirm all warm and poo poo no dont worry im cool yo you got any disesase tho"
|
# ? Feb 10, 2014 00:10 |
|
k-d tree is your first port of call when you're dealin w/ geometric information, as are tries when you're dealin with strings and b-trees when you're accessing external data. you're right though, they're not on par w/ the rest. she should definitely know her some hashmaps n set implementations though
|
# ? Feb 10, 2014 00:12 |
|
dont make it weird
|
# ? Feb 10, 2014 00:15 |
|
MononcQc posted:I liked The Algorithm Design Manual by Steven Skiena (PDF). It reads easily and will be a good intro to basic algorithms in many categories, and can be used as a stepping stone if you need to dig in deeper later on. seconding this is a v good real world design approach. CLRS teaches the standard elements but not really how and when to use them
|
# ? Feb 10, 2014 00:23 |
|
coffeetable posted:k-d tree is your first port of call when you're dealin w/ geometric information, as are tries when you're dealin with strings and b-trees when you're accessing external data. you're right though, they're not on par w/ the rest. r-trees would like a word (postgis = rtrees over GiST more or less) realtalk the best algorithm is one written and tested by someone else so "use a package manager" is probs the best approach
|
# ? Feb 10, 2014 00:25 |
|
coffeetable posted:answering your question directly without commentin' on the worth of learnin these things vs other skills, off the top of my head the next ones to look at (in priority order) would be yes, yes, yes, yes,lmao no, nope b-trees and such are great if u wanna learn how modern filesystems and databases work but are a very specific structure (and v complex)
|
# ? Feb 10, 2014 00:26 |
|
USSMICHELLEBACHMAN posted:Breadth/Width searches on graphs/trees you mean breadth/depth first search? (I'm being pedantic to help you)
|
# ? Feb 10, 2014 00:33 |
|
Malcolm XML posted:r-trees would like a word (postgis = rtrees over GiST more or less) Malcolm XML posted:yes, yes, yes, yes,lmao no, nope
|
# ? Feb 10, 2014 00:44 |
|
for standard interview fodder though yeah you're right both are pushing it. shoulda stopped tryin to think of common ones after tries
|
# ? Feb 10, 2014 00:47 |
|
Thanks i will ummm take all of this into consideration
|
# ? Feb 10, 2014 03:10 |
|
im just gonna do a bunch of eulers
|
# ? Feb 10, 2014 03:19 |
|
codility will better prepare you for interviews than euler, i think
|
# ? Feb 10, 2014 03:40 |
|
USSMICHELLEBACHMAN posted:okay I've learned how to implement the following data structures and algos today: if someone's been reading their algorithmic puzzle book, you're always in for a arduous interview. i am pretty much convinced this is normally to justify the interviewer's computer science degree, because they have rarely had any opportunity to use this stuff in production. classic things are reversing a linked list without overhead, so write just a reverse first, and then optimize it. there will be some linear time algorithm where the trick is doing two scans over the collection, once to find a number, value, depth, item, and a second pass occasionally you'll get a divide and conquer thing, like quickselect. always write the simplest algorithm that works. and by simple i mean, slow, verbose and in parts. break it down into tiny, tiny pieces and assemble it slowly. don't try and write the whole thing top to bottom. as for when you get asked to write binary search, remember this one weird old tip: are you writing a lower bound or an upper bound: http://canhazcode.blogspot.co.uk/2012/02/we-need-to-talk-about-binary-search.html quote:I haven't done hashmaps. Knowing the basics of hash tables might help you a bit, especially on collisions. quote:I can only fit so much more in my head in the next couple days. I really want to nail this interview so I can go from a hobbiest terrible programmer to an official terrible programmer. some of the crap up there is worth repeating about coding and algopuzzles in interviews: - read this: http://canhazcode.blogspot.co.uk/2012/02/we-need-to-talk-about-binary-search.html - be patient and methodical: write highly explanatory code, deconstruct it into plenty of functions and methods - don't solve it all at once, either. if it is to be fast, linear and correct, get it correct *first* - algorithms always have a trick to them. sometimes it's divide and conquer, sometimes it's that linear time can mean multiple passes over the data. finally, when you get an algopuzzle, don't ask the interviewer "when was the last time you used this in production code", because they don't like saying "oh, we never use anything like this" because it makes them look and feel stupid. if you want to rub salt on their wounds, just say "I just want to know if this interview reflects the sort of work I may be hired to do" actually don't do that, but it's really funny and I do it every time.
|
# ? Feb 10, 2014 03:44 |
|
tef posted:finally, when you get an algopuzzle, don't ask the interviewer "when was the last time you used this in production code", because they don't like saying "oh, we never use anything like this" because it makes them look and feel stupid. if you want to rub salt on their wounds, just say "I just want to know if this interview reflects the sort of work I may be hired to do" heh my last interview was stuff like "you have a pool of unreliable servers, how do you decide which one to try first? what if one's had higher-than-normal error rates? what if they've all had higher-than-normal error rates? should you fail loudly or just not succeed very often?" important stuff
|
# ? Feb 10, 2014 03:48 |
|
Cocoa Crispies posted:heh my last interview was stuff like "you have a pool of unreliable servers, how do you decide which one to try first? what if one's had higher-than-normal error rates? what if they've all had higher-than-normal error rates? should you fail loudly or just not succeed very often?" were they fishing for a discussion of the byzantine generals problem?
|
# ? Feb 10, 2014 03:50 |
|
Notorious b.s.d. posted:were they fishing for a discussion of the byzantine generals problem? not really, i was already familiar with CRDTs and the basics of distributed poo poo e: like the cap theorem
|
# ? Feb 10, 2014 03:55 |
|
if you want just good algo practice the UVa online judge is pretty great. i used it a lot when prepping for the ibm acpc
|
# ? Feb 10, 2014 04:38 |
|
I did a thing to play around with the Maven release plugin and gently caress around some more with logback. https://github.com/hiro2k/logback-twitter
|
# ? Feb 10, 2014 06:36 |
|
Janitor Prime posted:I did a thing to play around with the Maven release plugin and gently caress around some more with logback. my startup is so open source that our app logs to twitter
|
# ? Feb 10, 2014 07:57 |
|
qntm posted:Hoisting doesn't explain this at all. Even if JavaScript had block scope and i only existed for the interior of the loop, you would expect to see the same behaviour. You can see that i is being modified ("i++") for each successive iteration, not created anew. All the closures therefore refer to the same i, which, at the end of the loop, has value 10. yeah you are right. My mistake
|
# ? Feb 10, 2014 08:29 |
|
my feeling on scoping is that there are scopes. if you stick to general usage they will behave predictably. if you do weird stuff have fun with your scopes not making suns also if you are a fan of scoping dont use javascript
|
# ? Feb 10, 2014 09:08 |
|
|
# ? May 28, 2024 16:11 |
|
Cocoa Crispies posted:what if they've all had higher-than-normal error rates? then higher-than-normal is the new normal, pick a server at random
|
# ? Feb 10, 2014 10:04 |