Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
tef
May 30, 2004

-> some l-system crap ->

qntm posted:

hooray, everybody has abandoned timezones

oh wait, the past still exists and there are loads of dates and times there

oh wait, every country moved to UTC on a different day, and some refuse to move at all

i'm fine with this.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

prefect posted:

i'm thinking people would get mad if noon came around and the sun wasn't somewhere in the general overhead area

railway time :argh:

tef
May 30, 2004

-> some l-system crap ->

Nomnom Cookie posted:

why can't we have an api to turn (date, time, locale) into UTC and back again. thats all i want

*stores local time as utc* *dst changes by law* *all appointments an hour off*

tef
May 30, 2004

-> some l-system crap ->

Nomnom Cookie posted:

most of the time this is acceptable

just like 99% of java code only supports unicode BMP and no one notices or cares

do you work on the android team :3:

tef
May 30, 2004

-> some l-system crap ->
*adds one to year* *crashes in leap year*

tef
May 30, 2004

-> some l-system crap ->

prefect posted:

is this a religious thing, or was there some guy named church who thought them up?

it's because functional programmers believe in the separation of church and state

tef
May 30, 2004

-> some l-system crap ->
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/hJHCAaiL0so

quote:

Gofmt was written to reduce the number of pointless discussions about
code formatting. It succeeded admirably. I'm sad to say it had no
effect whatsoever on the number of pointless discussions about syntax
highlighting, or as I prefer to call it, spitzensparken
blinkelichtzen.

One step at a time.

tef
May 30, 2004

-> some l-system crap ->
ruby: has objects that respond to messages. this invokes methods. has lisp-2 style namespaces for method calls and variables. uses observer/internal iterators pushing a callback to the object. uses require/include to build scripts.

python: has objects that have attributes. this invokes functions. single namespace. self is lexically scoped. uses external iterators that return a value. has a library system.

both imperative call by object style scripting languages hth

tef
May 30, 2004

-> some l-system crap ->
heh https://www.youtube.com/watch?v=TFxRSV9cucM :toot:

ft: mr scruff https://www.youtube.com/watch?v=jZHAb92E31E

tef fucked around with this message at 03:41 on Jun 27, 2013

tef
May 30, 2004

-> some l-system crap ->

prefect posted:

semi-serious question: what's the serious engineer-scientist opinion of things like ip, tcp, and http? are those masterpieces of engineering design, or are there chunks of them that are the equivalent of spit and baling wire, things that work despite themselves?

the best design decision in tcp was to split it into ip and tcp. tcp itself is a good idea: pretend a packet switching network is really a phone network, and making calls between computers, but early tcp also caused network collapse (congestion control), it was vulnerable (syn flooding) and has a number of just unused or broken features (tcp urgent).


the real problem with tcp is that it is fossilized. now it's hard to change tcp because of nat shitboxes + smart routers, as well as being burnt into kernels, instead of in userland. applications can't control tcp flow or congestion, so many flock to udp to get what they want (like not saturating bandwidth)

tcp is really a stream atop of messages, but people tend to send messages over tcp, so they kinda end up reimplementing flow control + acks + timeout over tcp. many attempts to shoehorn a message protocol over tcp also suffer from a lack of multiplexing as well as head of line blocking too. tcp in some ways is too high an abstraction for messaging protocols.


for example: http and websockets. http can't be multiplexed, and pipelining isn't great as a substitute. websockets has to implement acks, timeout and flow control atop tcp too. http itself isn't really a masterpiece of design as implemented, but the intentions behind it are rather neat.

instead of abstracting things as special sockets, or a series of weird and ad-hoc methods, http works more like a filesystem, and through this allows proxies, caches, loadbalancers, as well as gateways to non http services. http is a a badly implemented protocol that makes the web work so well. still, it has weird things like line folding and a series of workarounds for older versions.


meanwhile in opposition to tcp/ip there is this idea of named data networking/content addressable networks, the idea that sometimes getting a file is more important than talking to a specific computer. bittorrent makes an excellent example of doing this end-to-end/at the application layer without having to have new routers. instead of asking for a file on a given computer (i.e a url), you ask nearby computers for the file you're after.

tef
May 30, 2004

-> some l-system crap ->
http/tcp/ip is just the most recent in a long line of good ideas executed badly and misused

tef
May 30, 2004

-> some l-system crap ->
basically tcp is a skeuomorph for the phone network :q:

tef
May 30, 2004

-> some l-system crap ->

FamDav posted:

a) what language implements an associative container and calls it an hash table instead of a map?

perl, ruby.

python calls it a dict, not a hash or a map.

quote:

c) i was curious what go's underlying implementation for map is and the spec doesnt even give algorithmic complexity for its operations. thanks rob.


quote:

hashmap.c is a multilevel hash table (a short tree so that it doesn't
have to be contiguous in memory; the tree grows as the table needs
to). Collisions are handled by linear probing.

http://golang.org/src/pkg/runtime/hashmap.c

tef
May 30, 2004

-> some l-system crap ->

FamDav posted:

why cant they put that in their spec? i realize that the implementation of their map type is changing every day but i would appreciate it if i could just go read through the spec and have a general understanding of the performance characteristics of basic types.

because it might be a property of the implementation, rather than the design :q:

tef
May 30, 2004

-> some l-system crap ->

trekdanne posted:

I ran into this "problem" with Python scoping. I know that Python uses statical scoping but that doesn't really work that well with the lambda keyword.

What does the following program output?
code:
a = []
for i in xrange(5):
	a.append(lambda x: i + x)

print a[1](1)
a) 2
b) 5
c) -1

Answer: b) 5

the i is stored in the outer scope, and not copied into the lambda, so i keeps the value from exiting the loop.

code:
a = []
for i in xrange(5):
	a.append(lambda x, i=i: i + x)

print a[1](1)
happy now ?

tef fucked around with this message at 11:49 on Jul 20, 2013

tef
May 30, 2004

-> some l-system crap ->

:getin:

tef
May 30, 2004

-> some l-system crap ->
ps should i make a smart dog book thread in CoC and then argue about stuff?

tef
May 30, 2004

-> some l-system crap ->

Jerry SanDisky posted:

no, calling set() on a list comprehension is not a set comprehension

(ps technically he called it on a generator comprehension).

(pps you don't need to return a list, a set would be fine I think)

tef
May 30, 2004

-> some l-system crap ->
i'm guessing that the set-comprehension is mostly implemented in C, so python can go woosh. with the generator comprehension, some extra work is done, and a bit of indirection to build the set.

tef
May 30, 2004

-> some l-system crap ->

just a butt posted:

I probably should have read the PL thread before post post posting cause they were literally talking bout cucumber which was what I was thinking about

you only need to read it once it's basically the same three arguments over and over again

-- checked exceptions
-- plangs vs jlangs
-- hay is java pass by value or pass by reference

tef
May 30, 2004

-> some l-system crap ->
someone counted all the little languages used to build a rails app and got to thirteen

tef
May 30, 2004

-> some l-system crap ->
covariant arrays are like this: eh eh eh eh


contravariant arrays are like this: do do do do

tef
May 30, 2004

-> some l-system crap ->

JewKiller 3000 posted:

it's not a difference of opinion, covariant arrays are objectively wrong by the only reasonable metric: they make type checking unsound

that said, if you're worrying about variance, then you're using subtyping, so you've already lost

yeah covariant arrays are pretty wat, they only made sense as a workaround for a lack of generics. however, there is a use for covariance outside of arrays, but i guess you know this so whatever.


my real problem is now when people say LSP i don't think of the substitution principle first

tef
May 30, 2004

-> some l-system crap ->

Mido posted:

UserManager::GetUserManager()->findUser("Mido")->setLaughs(UserManager::GetUserManager()->findUser("Mido").getLaughs()+1);

[✓] Global Variable, or as we call them now, Singleton Pattern
[✓] Getters and Setters instead of methods that do things
[✓] Possible Race Condition

:shrek:

tef
May 30, 2004

-> some l-system crap ->

Shaggar posted:

singletons have valid uses and db proxy objects is one of them (assuming that's what usermanager is)
the getter setter stuff on a db proxy is still dumb tho and my guess is hes not wrapping that in a transaction so the race condition is still a problem.

I have no objection to passing in a singleton, but it seems a bit bad to use a global to find it, it can make code harder to test and in effect tightly coupling parts together.

tef
May 30, 2004

-> some l-system crap ->

Shaggar posted:

in my case the singletons im pulling out of a global store (spring proxies) implement a specific interface. I pull them out of spring and shove them into whatever is using them. Then my tests can be built against the interface and I can inject proxies the same way to test implementations.

you'll note in the example above it pulls it out of a global and doesn't use a dependency hth

tef
May 30, 2004

-> some l-system crap ->

Shaggar posted:

oh, you mean tests on the proxy consumer. right. my bad.

tef was right




i think i need to go and sit down

tef
May 30, 2004

-> some l-system crap ->

MrMoo posted:

They asked yesterday what is 224?

It's 224? This is a perfectly fine way to represent the number

tef
May 30, 2004

-> some l-system crap ->

Mido posted:

but once your python poo poo starts growing into like 5 class monstrosities that break into 12 different files you're gonna start not enjoying all the duck typing bullshit when your poo poo breaks

unless you unit test the gently caress out of whatever awful thing you're doing

yep

tef
May 30, 2004

-> some l-system crap ->

PrBacterio posted:

I really do wonder though how regex based languages became so utterly dominant to the point that the "regexes" they parse arent even regular anymore but some sort of hybrid hellspawn of backtracking and exponential running time, when context free grammar parsing has been a solved problems for so long now. I mean obviously snobol and its successors are poo poo too, but why havent any modern, usable CFG based parsing languages been invented for whats literally decades now, when its quite obvious to anyone with a brain that regexes arent really what people actually want or need for parsing in most cases as, for one, what people call regexes nowadays actually arent

because debugging lalr is painful, recursive descent is easy, and ll is really loving trivial and lr isn't. actual cfg parsing is still slow and clumsy.

tef
May 30, 2004

-> some l-system crap ->

Shaggar posted:

the javadocs. java is great and easy and you don't really need a book, just don't try to replicate what you did in those hosed up and lovely p-langs cause it was probably wrong.

this is wrong, you probably want "Effective Java" by Joshua Bloch. It's a cookbook of good ways to use Java

tef
May 30, 2004

-> some l-system crap ->

Notorious b.s.d. posted:

i believe shaggar was referring to the official oracle/sun tutorial content, not literally the docs generated by the javadoc tool

effective java is a pretty good book tho

tef
May 30, 2004

-> some l-system crap ->
doesn't windows use nt paths internally and exposes dos style paths for compat?

tef
May 30, 2004

-> some l-system crap ->

PleasingFungus posted:

I kind of want to learn an erlang but I don't know what I could use as a learning project

chat server ?

tef
May 30, 2004

-> some l-system crap ->

MeruFM posted:

it is, my post was just worthy of this thread
default scope is still weird to me though

Python has no scoping other than import management, everything is public (except when it isn't, talk worthy of the other progrmaming thread). _ and __ are prepended to variables to let people know you shouldn't touch them, one scopes at the import level, the other fucks with the var name so it's harder to use.

lolpython

you mean visibility, right? not scope

tef
May 30, 2004

-> some l-system crap ->

MononcQc posted:

Print statement debugging has been my bread and butter of debugging. Languages that allow tracing make that easier. When all else fails, I get a piece of paper and pencils and I think really hard.

It's hard to run debuggers in production systems, especially after they've crashed. I found that many of my debug statements were worth keeping after the bug was found. Logging is lovely.

tef
May 30, 2004

-> some l-system crap ->

USSMICHELLEBACHMAN posted:

replace catch with tweet imo

code:
try {
   fh.close()
} tweet (FileIOTweet t)
   // todo
}

tef
May 30, 2004

-> some l-system crap ->

USSMICHELLEBACHMAN posted:

okay I've learned how to implement the following data structures and algos today:

What am I missing?

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.

tef
May 30, 2004

-> some l-system crap ->

Innocent Bystander posted:

also, I got asked this question at two different shops: Find the intersection between two strings (in C). What is its runtime? If I gave an O(n) solution, they would ask me to give a O(n^2) solution, if I gave an O(n^2) solution they asked me to do it in O(n). hth


so you want to find the common elements between two lists of characters

option a) use a hash table, or a array

option b) if list is sorted, merge the common elements.

option c) two nested for loops

common subset? build a suffix tree i think eh it's 6 am

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Malcolm XML posted:

is this for set or multiset instersection tho

does it make a difference?

a) use a hash, keep count of how many elements are in a set. find the intersection of hash keys + sum of hash values (or same but use array with counts)

b) if mutiset is expressed as sorted string, merge them, skipping ones that only appear in one string, keeping duplicates

c) two for loops

  • Locked thread