Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31271

Re: How would you prepare for javascripting interview?

From Doc O'Leary <droleary@2015usenet1.subsume.com>
Newsgroups comp.lang.javascript
Subject Re: How would you prepare for javascripting interview?
Date 2016-09-07 19:53 +0000
Organization Subsume Technologies, Inc.
Message-ID <nqpr7i$l7t$1@dont-email.me> (permalink)
References (7 earlier) <nqf8t7$h37$1@dont-email.me> <nqhg6o$st6$1@dont-email.me> <nqkl2e$6bt$1@dont-email.me> <nqmpag$kit$1@dont-email.me> <nqo0jf$a4v$2@dont-email.me>

Show all headers | View raw


For your reference, records indicate that 
Scott Sauyet <scott@sauyet.com> wrote:

> Doc O'Leary wrote:
> > 
> > Then I wonder if you’ve ever done any sort of sophisticated programming.
> 
> I believe I have.  I've also been training programmers in advanced 
> techniques for a number of years.

How unfortunate for them, and anyone they’ve every worked for.  Care 
to name the institution, so that it makes it easy to exclude those 
people from jobs where people need to know how to do things right?  
Thanks.

> 
> >  There is a *reason* why languages developed mechanisms other than
> > “return a valid value and let the programmer figure out if it’s
> > *actually* a good result, or just some kind of error”.
> 
> I've argued (most recently in a response to Gene Wirchenko) that this is 
> not only a good result, but the only reasonable value.
> 
> It allows us to assert laws such as
> 
>     max([max(list1), max(list2)]) === max(concat(list1, list2))

The purpose of Computer Science is *not* to assert mathematical laws.  
It is to do useful work.  It is *wrong* to return a result *as if* 
useful work was done when it is highly likely such a result is not 
only in error, but will likely propagate that error.

> > It’s best dealt with abstractly, because the concept applies to things
> > other than numbers.  If you can order it, you can determine a “max”
> > value.  And if there is *no* values to order, it is ludicrous to say the
> > correct result is a valid value you have simply fabricated.
> 
> This is no more fabricated than 0 is fabricated as the sum of an empty 
> list of numbers, than 1 is fabricated as the product of an empty list of 
> numbers, or than `true` is fabricated as the result of a call to `all` on 
> an empty list.

They are all fabricated.  Done so to reflect their respective identity 
element, sure, but all of them are equally *wrong* behavior from a CS 
perspective.

> These are the obvious and useful results.

Internally, yes, they are useful in the way that many other hacks 
are useful.  But it is not the sign of a competent developer to 
architect a library that *always* returns valid results like that.  
Pull your head out of your math book and actually *think* about the 
work you’re trying to do.

> You clipped the bit where I mentioned custom types and how since the user 
> would already have to do the ordering, asking her to also signal the 
> proper behavior here is not unreasonable.

It is in a polymorphic sense.  Or do you expect max() to be 
implemented to return -Infinity by *all* developers for all objects?  
Again, I suspect you’ve never really architected a system of 
substantial complexity.

> I'm suggesting that those who define the types to be used with a generic 
> `max`/`min` would have to define their own boundary values, or signal 
> that they don't exist, not that such a function could do it for an 
> arbitrary type.  But I also insist that ±Infinity is the only reasonable 
> choice for Javascript's Number type.

And that kind of thinking is why a lot of people see JavaScript as 
amateur hour.  We don’t need some overwrought system to allow you to 
keep doing bad things out of a sense of mathematical purity.  All we 
need is a standard that says which operations need 0, 1, 2, or more 
arguments to produce behavior that makes (common) sense, and what 
the error behavior is when those pre-conditions aren’t met.

> This is simply the result of my suggestion that this should be left to 
> those implementing ordering for the types.  I don't know better than they 
> do; neither do you.

It seems I do know better, though.  And, worse, I happen to know from 
*experience* that your approach of just letting everyone do what they 
want willy-nilly results in exactly what I said: an utter mess.

> >> It's not that I think this is a bad point. I simply don't believe it's
> >> as clear-cut as described.
> > 
> > It is.  Perhaps one day you’ll be experienced enough to understand why.
> 
> It is not.  Perhaps one day you'll understand enough math to recognize 
> why.

My math is fine.  It’s your computer science that isn’t up to snuff.

> > I would seek to define a consistent behavior.  The *way* garbage comes
> > out is important.  That’s the entire issue of why an infinity is the
> > wrong result.
> 
> I was simply being flip here.  I apologize.
> 
> To me `null` or `undefined` would be true garbage.  Instead of a function 
> whose results I can simply use, I would get something that then requires 
> type-checking, and then manual intervention if I get the wrong type.  If 
> this throws, I cannot compose it with other functions, and need to build 
> complex logic flows rather than simple functional pipelines.

Your (local) simplicity can be maintained if you raise exceptions.  
The fact is that unexpected behavior and errors need to be accounted 
for.  You can’t just fall back to mathematical purity and say “Well, 
you’re going to have to live with the results that came back because 
it satisfies a proof someone made 400 years ago.”  Everything more 
complex than that comes at a cost.

> I have no fundamental issue with the thought of instead offering a `Maybe 
> Number` type (or more generally a `Maybe a` one) for an API, but this 
> whole discussion is in the context of a function already documented to 
> return a number.

Only because JavaScript defines it solely in Math.  Many other 
languages define similar operations more abstractly on collections.  
I encourage you to expand your thinking beyond mathematics to the 
real world uses of these things.  Talk to some actual humans about 
what *they* would say is the maximum value of 3, 2, 1, and even 0 
items.  I would wager a large amount of money that they’ll all agree 
to what the result should be down to 1 item, and that essentially 
*nobody* would offer up -Infinity as the result for 0 items.

> If you have a solution for it, do you always throw on an empty list, do 
> you always return a `null`/`undefined` signal, or do you leave it up the 
> type to decide?

That’s just it: for an empty list, abstractly, there is no “type” of 
the nothing it contains.  The behavior you choose has to be 
consistent with all kinds of objects.  So, sure, it might make the 
most sense to raise an exception, even for functions like sum() that 
might otherwise commonly return a 0 value for numbers.

> I don't know what sort of position you hold.  I work in a large company 
> with an ongoing mix of old and new software for developers to work on.  A 
> very important skill is trying to figure out how a system or a component 
> works, and why it's written the way it is.  Watching a candidate go 
> through this exercise, I believe, helps me determine how skilled she is 
> at this.

Not really.  Again, you stop with the hack itself when the *real* 
demonstration of CS skill is everything we’re discussing here.  It is 
trivially easy to discover and put up with bad code, because bad code 
is everywhere.  That is not a rare skill you need to select for.  The 
places I aim to work for are the ones that appreciate the need to get 
to solutions that are *better* than existing ones.

-- 
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 09:10 -0700
  Re: How would you prepare for javascripting interview? Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2016-07-18 18:37 +0200
    Re: How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 11:09 -0700
      Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-07-21 01:04 +0000
        Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-07-21 14:24 +0100
        Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-23 16:25 +0200
          Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-07-23 15:56 +0000
            Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-03 19:39 +0000
              Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-04 15:56 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 00:06 +0100
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-05 14:49 +0100
                Re: How would you prepare for javascripting interview? $Bill <news@todbe.com> - 2016-09-05 10:01 -0700
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-06 09:36 -0700
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-05 15:05 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-05 20:31 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 15:15 +0000
                Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-09-06 19:40 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-06 19:25 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-06 22:16 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-07 17:17 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-07 20:07 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-08 14:36 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-05 18:46 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 20:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-05 17:27 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 20:12 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:48 +0000
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-06 19:56 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 20:16 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-07 10:01 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 20:21 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-09 11:41 -0700
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-09 15:35 -0700
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-09 20:40 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 15:12 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-12 11:14 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-13 21:07 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:20 +0000
                Re: How would you prepare for javascripting interview? Ken Tilton <kentilton@gmail.com> - 2016-09-05 11:37 -0700
                Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-09-06 19:26 +0200
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-08 12:41 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-05 20:37 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 22:13 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-06 02:33 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:02 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-06 09:50 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-07 01:36 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-07 10:07 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 00:03 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 00:12 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 15:34 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-11 01:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 19:26 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-13 01:02 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-13 21:38 +0000
                Re: How would you prepare for javascripting interview? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-09-14 00:56 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:09 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-14 00:47 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:34 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-11 02:45 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 19:10 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-12 21:06 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-07 03:12 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 19:53 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 02:14 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-10 11:25 +0100
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-10 15:49 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 18:39 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-11 02:45 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-11 16:23 +0100
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-12 20:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 18:49 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-13 00:27 +0000
                Re: How would you prepare for javascripting interview? Tim Streater <timstreater@greenbee.net> - 2016-09-13 08:51 +0100
                Re: How would you prepare for javascripting interview? Jon Ribbens <jon+usenet@unequivocal.eu> - 2016-09-13 12:33 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-14 01:17 +0000
                Re: How would you prepare for javascripting interview? Tim Streater <timstreater@greenbee.net> - 2016-09-14 11:15 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:02 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-13 10:06 +0100
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-06 19:53 +0100
    Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-18 22:30 +0200
  Re: How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 14:56 -0700
  Re: How would you prepare for javascripting interview? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-07-19 16:01 -0300
    Re: How would you prepare for javascripting interview? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-07-19 16:16 -0300

csiph-web