« first day (1082 days earlier)      last day (3854 days later) » 

7:03 PM
@Cerberus Yes, exactly what I said. When Google is selling it, they sell it at their price. When Google isn't selling it, someone else is, and they sell it at the higher price.
So my suspicion is that Google is prevented from, or not interested in selling phones directly in every European country.
 
@Mr.ShinyandNew安宇 But what explains the price difference? And, besides, it's still a lot more expensive in EUR than in CAD.
@Mr.ShinyandNew安宇 But why? And why would the forbidden countries happen to be the smaller countries?
 
@Cerberus It's not that much more expensive in EUR vs CAD. the EUR price probably includes VAT while the CAD price does not.
 
How much is VAT?
 
@Cerberus Let's say a country requires you to jump through certain regulatory hoops before you can sell a cellphone. Like, the USA requires FCC certification.
Now let's say that Google wants to sell in your country, but the regulatory costs or other startup costs are too high to justify it at this time.
Then it would be reasonable for them to contract sales out to someone else.
That person can't get the phones for Google's price because they have to mark it up to be profitable.
 
They are too high for Google, but low enough for 10+ Chinese manufacturers?
 
7:07 PM
@Cerberus Why hasn't Google launched ALL its products in every country? Evil conspiracy? Or just "it takes time and money and they haven't done it yet"
 
@Mr.ShinyandNew安宇 It's LG that's selling the phone here. And why would they have to mark it up while Google would not? Besides, "have" is just not the right word: they make a profit either way, the BOM is likely under € 200.
 
@Cerberus and how much is the fish?
 
@Cerberus And of course, there are no other costs involved in making a phone besides its BOM.
 
@Mr.ShinyandNew安宇 I rather think it is because they want to make sure those markets are well served where Google sells music and stuff through their shop. And they didn't want to make enough of an investment to make enough phones for the entire world.
 
My BOM is on your lips. Kiss VAT BOM.
 
7:09 PM
What's BOM?
!!define BOM
 
@KitFox BOM Bill of materials; a list of items used to make an assembled item.
 
Oh.
snorts
 
@Cerberus So time and money, as I said. "not interested".
As for why LG is selling the phones for a higher price, perhaps they just don't want to cannibalize the sales of their other phones.
 
@Mr.ShinyandNew安宇 Of course there are, but those aren't marginal costs, and only those are relevant to the decision "shall we sell in Holland or not?". There will be some other marginal costs on top of the BOM + manufacturing, but not that many, and certainly nothing remotely close to the € 150 that you need to arrive at the German price (€ 350, presumably). And of course there is the Canadian price as exhibit A, which is a lot lower than € 350, and they still make a profit on that.
 
@Cerberus Are you sure there are no other marginal costs?
 
7:11 PM
@Mr.ShinyandNew安宇 Not time and money, but return on investment.
@Mr.ShinyandNew安宇 Or, rather, because they can. See the "basis" I mentioned earlier.
@Mr.ShinyandNew安宇 I said "some other marginal costs". Think transportation and administration.
 
@Cerberus how is "return on investment" different from "time and money"? They don't want to spend the time and money on it.... dun dun dun... because the return is too low!
 
Okay, if you define it that way.
 
@Cerberus patents, licensing fees, regulatory fees, etc.
 
Those aren't marginal.
 
Sure they are.
Or, at least, they could be.
patent fees are often per-device.
 
7:14 PM
Another hypothesis: perhaps LG has demanded that Google not sell them everywhere, for the cannibalisation reason you mentioned.
 
Taxes, etc, are per-device. Tariffs. etc.
 
But all countries have tariffs.
 
@Cerberus I doubt it. I guess it's possible. I think it's just that Google has decided to focus on certain national markets first, and those ones get the phones from Google, and the rest don't (yet).
@Cerberus Well, not necessarily. e.g. Canada can import phones from the US for free.
 
@Mr.ShinyandNew安宇 At any rate, all those costs cannot be high, considering how cheap non-A-brands sell their phones.
And how cheap e.g. Samsung sells its budget phones.
@Mr.ShinyandNew安宇 But not from China.
Tariffs are already pretty low for these kinds of products anyway.
 
@Cerberus Samsung's budget phones have lower costs, both design-wise and BoM-wise, than their flagship phones. Lower advertising costs, lower profit margins, etc.
what is the typical VAT in germany for phones? do you know?
 
7:17 PM
No, but it's 21 % here.
It will be slightly less there.
 
19% according to wikipedia
So if you take the VAT off the European price, then convert EUR to CAD, € 350 becomes $423
 
@Mr.ShinyandNew安宇 Yes, but they still make a profit on a phone that costs € 80 including VAT that can do all the things any Smartphone can. I've read this in several places: transportation and tariffs really aren't a huge factor.
@Mr.ShinyandNew安宇 So that's a 21 % mark-up.
 
Which is unremarkable considering how much many other things are marked up, like Uggs.
But € 460 is remarkable.
That's ca. CAD 550 if you subtract VAT.
A mark-up of 57 %.
 
That's just slightly lower than what I'd expect to pay for a smartphone from anyone except Google.
 
7:23 PM
Remind me about equivalency conditions in javascript. If I say ltime == 0 where ltime is an integer, will that evaluate as I like?
 
Thanks.
 
but to be sure you should probably use ===
 
Yeah, € 460 would have been a normal price here for a lower-high-end smartphone.
 
That tests the type too?
 
7:24 PM
(which, btw @cerb, is an example of how a language shouldn't try to be too helpful for beginners, because it makes programming harder for experts)
 
Huh what?
 
1297
Q: Does it matter which equals operator (== vs ===) I use in JavaScript comparisons?

bcaspI'm using JSLint to go through some horrific JavaScript at work and it's returning a huge number of suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value.length == 0 inside of an if statement. Is there a performance ben...

 
Oh, actually, can you explain this to me? Because I'm not sure I understand what this does.
 
It is of course true that making a language easier for beginners can make it harder for intermediates or even experts.
 
@Cerberus in JS they tried to be "helpful" by doing automatic type conversion with certain operators. So you could do 0 == "0" and it would be true. This turns out to be great for tiny, shitty programs, but awful for real programming.
 
7:25 PM
var interval;
        interval = setInterval('change()', 60000);
Is that calling the function "change" every minute?
 
@Mr.ShinyandNew安宇 Why is it awful, and why can't that problem be solved?
 
Can I shorten it to var interval = setInterval('change()', 60000);?
 
@Cerberus it's awful because it's a source of major bugs and surprises. It can't be solved for reasons of backwards compatibility, unless you require real programmers to do things differently. Which is a problem because it gets rid of one of JS's advantages, which is similar syntax to other languages.
@KitFox yes
@KitFox do you want me to explain setInterval?
 
Yes, if you don't mind. I don't think I understand it.
 
@Mr.ShinyandNew安宇 So what's the problem?
 
7:27 PM
It looks like setting a callback.
 
@Mr.ShinyandNew安宇 wow Bill worked so hard for that Great Answer. Mine is three words.
 
setInterval: Calls a function or executes a code snippet repeatedly, with a fixed time delay between each call to that function.
So yeah, it sets up a timer which fires every 60000ms. That timer executes the string 'change()' which is eval()ed
I prefer this approach: setInterval(change, 60 * 1000);
 
Yeah, that's what I thought. So it is like creating a callback or an event-type thingy.
 
in my syntax I pass in a function pointer
I find that more clear
Also I break out the MS value into components that are easier to read
 
So if I want to shut it off? I thought I could clear it by setting it to zero, but that doesn't seem to work.
Oh. clearInterval?
 
7:30 PM
@Cerberus The problem is that in most languages with a C-like syntax (like JS uses) you compare things with ==. so 1==1 is true, and 1==2 is false, and 1 == "1" is false, because "1" is a string and strings are not the same as numbers.
 
Yes I got that, but why is it a problem?
 
Type conversion.
You write data collection pages, you won't have to ask why that's a problem.
 
@KitFox yes, clearInterval(interval)
 
Thank you.
 
@Cerberus in JS 1 == "1" is true. Because it automatically converts the type for you.
 
7:31 PM
checks off 'learned something today' box
 
1 min ago, by Cerberus
Yes I got that, but why is it a problem?
 
Type conversion means that it's easy to screw up your comparison. You expect two things to be different, but they happen to be the same under certain circumstances.
 
In practice?
 
Oh yes.
 
7:33 PM
It's such a big problem that JS added new operators that DON'T do type conversion.
So now that JS was designed badly from the start, if you want to be SURE about what your program is doing, you have to use === to compare things.
Example. '' == '0' is false but 0 == '' is true and 0 == '0' is true.
 
Okay, so...
When would it be a problem?
And, if you have a special === for comparing in a stricter manner, is it still an issue at all?
 
It's a problem when you want to make a distinction between null value and zero value, for instance.
And in the special case, when you don't want to make a distinction between them.
 
You can always query whether the value is a string or not to distinquish between 0 and '0'?
When is this a problem in practice?
 
And how will you do that?
It's a problem in practice when it makes a difference if the value is null or zero.
 
@Cerberus It's a problem because most people who find themselves typing a C-like language use == by muscle memory. This is often an error. It leads to programming bugs when you have a value which can be null OR zero, both of which are considered the same when testing.
 
7:45 PM
If var is [not] type
Checks whether a variable's contents are numeric, uppercase, etc.

if var is type
if var is not type Parameters
var The variable name.
type See the remarks below.

Remarks
Supported Types:

integer True if var is non-empty and contains a purely numeric string (decimal or hexadecimal) without a decimal point. Leading and trailing spaces and tabs are allowed. The string may start with a plus or minus sign.
float True if var is non-empty and contains a floating point number; that is, a purely numeric string containing a decimal point. Leading and trailing spaces and tabs a
 
Ugh. Why would you do that?
 
So in AHK you can do "if var is number" to check whether it's a number, presumably.
@Mr.ShinyandNew安宇 So it is mainly a problem because people are used to a different convention?
 
@Cerberus Yes, it's firstly a problem because it mimics another language improperly. But it's ALSO a problem because it exists at all; the default condition of the language is to be buggy and insecure. People who want to do things properly have to work harder (type an extra char, in this case)
 
I still don't get it. Perhaps a practical example would be too advanced for me.
 
@Mr.ShinyandNew安宇 Two for me, because I work in VB all the time.
Which is a whole nother can of worms.
@Cerberus "What is your child's text reading level?"
 
7:50 PM
@Cerberus I'm searching for an example of actual bugs caused by this.
 
There is a difference between zero and null.
If it is a required field, then null should not be allowed.
For instance.
Also, null should not be included on a chart or in a calculation.
And it should really not be counted as a zero.
 
But in those rare cases where a distinction between 0 and '0' is important, you could set an extra condition "if var is number".
Or simply use ===.
Or ask for an errorlevel.
 
Yes, "or simply use" of course. You are the one asking why it matters.
And the distinction between 0 and '0' is not all that rare, since the textbox input values are read as strings and not numbers by default.
 
I should think making them equal is useful in more cases.
 
Here's an example that uses PHP instead of JS, but the problem is the same: joncave.co.uk/2013/03/…
 
7:56 PM
@Cerberus Oh probably. So pop quiz without looking back at the script, is that two equals or three?
 
if (md5($data . $this->get_random_signature()) == $signature)
 
I'm afraid I don't speak the language.
 
the md5 function always returns a string. But that string could start with an integer
 
Ouch.
Even I could hack something like that.
 
55ad340609f4b302, for example, is an MD5 signature
the $signature variable is user-controlled
So the user can pass in an integer value
if the user can pass in 55 as their $signature, then '55ad340609f4b302' == 55 will be true
even though that's absurd
 
7:58 PM
Huh.
But why would that be true?
 
Because that's how the type coercion works.
it takes all the leading digits and makes them a number
 
But 55ad340609f4b302 should not be automatically converted into 55.
 
Well, that sounds like a bad idea.
 
if you try to do number-y things with it. like math, or comparison to numbers.
 
8:00 PM
Why would you even want that?
 
No, it's a good idea, see? you can easily convert strings like "55 carrots" into a number, so that you can find out how many carrots you have.
 
Doesn't sound like a probably scenario?
 
Or you can convert text inputs into numeric ones.
Like when people are entering text reading levels.
 
@Cerberus No, that is the actual reasoning. For converting strings with leading numbers, where your data format is likely to contain such things.
 
If that's what you really want to do, make a function like "remove all non-digits".
Or "remove trailing non-digits".
 
8:01 PM
See, here's the thing. There's lots of ways a problem could be solved.
 
Later, my friends.
 
But I don't see that as equal to 0 = '0' with respect to problematicity. If that is a word.
 
Java, for example, does not do type coercion between strings and ints. or any primitive types, really. And it's really easy to write code that deals with numbers and strings and whatnot and not get confused.
@Cerberus For the same reason. If a user can control one of your inputs, they can maybe make your program do something dumb.
 
Too bad. Java has all the time in the world to do type coercion. Or really anything at all.
 
But it's just not the same thing.
From '0' to 0 is not the same thing as from '55hjgkjgf' to 55.
 
8:04 PM
@Cerberus No, it is. The fact that zero, null, '0', ' ', '', false, undefined, and a few other things in Javascript are "the same" leads to many problems.
 
The former I can image being convenient to be the default; the latter, I cannot.
@RegDwigнt Because it sits disabled in my browser with nothing to do?
 
Another example:
if ( $_GET['token'] != $oWpHelper->getTransient( 'worpit_login_token' ) )
$_GET['token'] is a user-controlled value
 
Jul 4 at 22:03, by RegDwighт
Knock-knock.
 
Why are you knocking?
 
$oWpHelper->getTransient( 'worpit_login_token' ) tries to get a value from the database, or returns false if there is no value there (that's a PHP idiom... )
 
8:07 PM
@Mr.ShinyandNew安宇 Then I would do "if errorlevel" to check whether or not a value was returned?
 
so if the user can control $_GET['token'] then they can send "0" and then you have "0" != false
@Cerberus I don't want to go into why returning false there is a bad idea.
 
Oh.
 
The point is that a user can provide something which sometimes gets turned into something else, if you by accident used the wrong operator. Most of the time, the code works, only sometimes, the code doesn't do what is intended.
If the programmer had used === or !== respectively, then the code would not have failed.
 
If you want to make sure, you can use ===? That sounds convenient?
 
No. It's not convenient.
 
8:09 PM
Why not?
Or set a switch "from now on, == does not autoconvert" at the beginning of your script?
Or wherever you need it.
 
It's not convenient because == is the "default" way of expressing "equals" in dozens of languages. Only in the broken type-coercing languages do you need to use "===". But to make it worse, the "==" is NOT a syntax error, so if you forget, your code is wrong, but you probably won't find out until it breaks in production and your security is bypassed or whatever.
 
Okay, so there's convention again.
I mean, I can see why it can lead to problems, but the converse can also lead to problems.
 
posted on October 28, 2013 by sgdi

Someone was sat on their own Waiting to not be alone They passed the short time Writing a rhyme Trying so hard not to moan

 
And it's easy to get around the problem by using === or some other way.
I have seen Matt tell people to use "var !== 1" instead of "var == 0" because some language would not autoconvert and "null" would not equal to "0" as some programmer expected.
So anyway, I'm sure it is a problem and all...but I think what Autohotkey does with %var% and "string" is a lot more confusing than this.
And a lot more problematic for intermediate users.
It's bitten me countless times.
 
@Cerberus You are downplaying how irritating and unhelpful it is if your language has a feature that gives incorrect results, which uses the same syntax as what you're used to typing, and which requires you to constantly remember to do something different in order to be right, and which doesn't obviously explode in your face when you get it wrong.
The difference in syntax alone is merely annoying. The problem is that it has two syntaxes, one right, one wrong.
in some languages, variable assignment is x = y. in other languages, it's x := y.
 
8:19 PM
It is difficult for me to judge, because so far I have only reaped the benefits of this default conversion, and I am not advanced enough.
 
When you type those incorrectly, i.e. use one syntax in the other's language, the language helpfully stops and says "whoa. You can't do that".
 
In Autohotkey, you can do either.
 
In Javascript, if you type "x === y" it works. If you type "x == y" it works, except sometimes it doesn't work.
When it blows up is when the hackers discover they can break into your app by violating its assumptions.
 
I still don't think that 55 example is at all similar. That drastically changes the content and removes a lot of bits from it.
 
fine, but the second example I gave didn't rely on that.
 
8:21 PM
Yeah but it didn't seem very problematic to me as a layman.
 
the second example is a security bug in a server management program. It's an in-the-wild security bug, where the user can compromise the server by fiddling with HTTP headers.
and that doesn't seem problematic?
 
Perhaps I didn't understand the example.
 
if ( $_GET['token'] != $oWpHelper->getTransient( 'worpit_login_token' ) )
let's simplify it
 
But for a database appearing to return '0' when in fact it returned nothing or an error doesn't seem that problematic or hard to counter.
 
if ( $user_supplied_data != $value_which_is_false_if_user_not_logged_in )
The code assumes that the $user_supplied_data is a string. It then compares it to another string, or false.
However because of type-coercion, the user-supplied data can be "falsey", that is, something which looks like false. i.e. '0'
Then the runtime evaluation is '0' != false
Which is false.
if ( $_GET['token'] != $oWpHelper->getTransient( 'worpit_login_token' ) ) {
die( 'WorpitError: Invalid token' );
}
 
8:26 PM
But why would you ever ask for the user's data in this way? Why not ask "if value in database, pass; otherwise block"?
 
That's the whole snippet. If the tokens don't match, the user isn't allowed through.
But the code fails if the user provides a token which looks like false
@Cerberus That is exactly what this code is trying to do: if the value is in the database, pass, otherwise, block. But because it uses != instead of !== it can be tricked.
Yes: type-converting operators can make some tasks easier. Especially for people who don't know what they're doing. But then they make everything else harder.
 
I'm afraid I didn't understand the example. It uses terms I don't know, like "Then the runtime evaluation is '0' != false".
 
@Cerberus At the time the program executes, it is comparing '0' to false
because the user provided their token as '0'
 
But why use a negative comparison?
 
and because a string can be compared to a boolean successfully, the comparison works, doesn't blow up, and the security is bypassed
@Cerberus Because they want to have a short THEN clause
IF (tokens don't match) THEN die
 
8:30 PM
Wait, is this about comparing user input to an empty cell in the database or something?
 
I think you're assuming I know stuff about programming languages. But you're using lots of symbols, functions, and terms I don't know.
I read it, but I just don't understand it.
 
I guess you'll have to just trust me, then, when I say that programming languages which are designed to make life easy for beginners are not a good idea
 
Heh.
But would you remove all kinds of defaults from a language?
I mean, surely any language has all kinds of defaults that you don't have to set but can change?
 
I would remove features that decrease consistency, and I would remove features that surprise people. Sometimes it's hard to tell 100% if a proposed feature will do one or the other.
 
8:34 PM
Indeed.
 
oh, you mean, would I make it so that programmers have to specify how they want the language to work?
like, a bunch of config switches at the top of a source file? No.
 
In Autohotkey, for example, if you do WinGetPos, it assumes you mean the active window if you don't add a parameter, but you can specify it by doing "WinGetPos, Firefox".
 
That would make life very hard for developers.
@Cerberus That's a different kind of default. That's okay.
Anyway I have to get going.
 
OK bai.
 
System.exit()
 
8:36 PM
Nooo don't shut us d—
disappears in CRT-screen-line animation
 
8:49 PM
pleased to meet you ... hope you guess my name
 
Lucifer?
 
@JohanLarsson damn ... that was supposed to be hard :-)
 

« first day (1082 days earlier)      last day (3854 days later) »