Live data from Hacker News

Nerdsniping: A glimpse into a stubborn mind

blog.andyet.com

51–60 of 94 posts

Re: Nerdsniping: A glimpse into a stubborn mind

#51
post #50
post #39

Earlier quoted context omitted.

Not all languages with getter/setter support will invoke them automatically like this. For example, it's not possible in Java or Objective-C to make an expression of the form a == b, where a and b are plain variables, have any side effects.

In Obj-C you can if you would allow `a.prop == b.prop`.

Sure, but then it's obvious that you're doing something beyond an equality comparison.

Re: Nerdsniping: A glimpse into a stubborn mind

#54

And this is why Javascript can be such an awful language. Leaving off a single equals has such a profound effect, often without a new coder even realizing it while reading the code. Imagine what happens to your code when someone tries to write a function for its side effects similar to the example seen in the blog post. Then releases it in production for it to break in six months with a feature change.

> Imagine what happens to your code when someone tries to write a function for its side effects...

The language used can hardly be blamed for that.

Re: Nerdsniping: A glimpse into a stubborn mind

#55

And this is why Javascript can be such an awful language. Leaving off a single equals has such a profound effect, often without a new coder even realizing it while reading the code. Imagine what happens to your code when someone tries to write a function for its side effects similar to the example seen in the blog post. Then releases it in production for it to break in six months with a feature change.

> And this is why Javascript can be such an awful language. Leaving off a single equals has such a profound effect, often without a new coder even realizing it while reading the code. You get used to this as you get seasoned with javascript. Every language has it's quirks. The human brain is remarkably adaptable to using tools & dealing with intricacies. I personally utilize & appreciate the difference between == and…

Nothing you said actually differs from what I said.

I spent seven years as a Perl programmer. Like Perl, a language can be extremely productive in the hands of a veteran and dangerous with a newcomer due to the unnecessary confusion it generates. At least eq and == are syntactically easier to grok than == and ===.

Re: Nerdsniping: A glimpse into a stubborn mind

#56

And this is why Javascript can be such an awful language. Leaving off a single equals has such a profound effect, often without a new coder even realizing it while reading the code. Imagine what happens to your code when someone tries to write a function for its side effects similar to the example seen in the blog post. Then releases it in production for it to break in six months with a feature change.

>"And this is why Javascript can be such an awful language."

To be fair, this is breaking Javascript and that is something you could do in other languages, for instance here is a similar version for C++:

http://pastebin.com/seySfpku

Re: Nerdsniping: A glimpse into a stubborn mind

#57
post #35
post #20

Earlier quoted context omitted.

Wasting other people's time is a negative, but deepening your understanding of a topic by examining edge cases is generally worthwhile, IMHO.

Is it really fair to call poor code an edge case? If not for the double-equals typo, which most code reviews would fix, this wouldn't work. I'm more interested that this team has conversations where person A asks a really simple question that should be able to be tested in 11 seconds, person B gives a patently false answer that mistakes && for ||, which is the very thing person A is asking about. Meanwhile person C g…

No, person C saw an interesting question, and decided to go on an exploratory journey to see what's possible. In any job requiring mental aptitude, you'll find natural curiosity an asset, as long as you keep it within bounds.

To be clear, anyone that's presented a question about a tool they are using that may pertain to it's use (be it efficiency or correctness) that shows zero interest in the answer (whether or not they have time to pursue an answer) is not someone I want to work with or manage, and should probably find another career, because the one they are in isn't holding their interest. Work doesn't have to be the most important thing to you, but if you don't like your job, the people around you WILL notice.

Re: Nerdsniping: A glimpse into a stubborn mind

#58

And this is why Javascript can be such an awful language. Leaving off a single equals has such a profound effect, often without a new coder even realizing it while reading the code. Imagine what happens to your code when someone tries to write a function for its side effects similar to the example seen in the blog post. Then releases it in production for it to break in six months with a feature change.

>"And this is why Javascript can be such an awful language." To be fair, this is breaking Javascript and that is something you could do in other languages, for instance here is a similar version for C++: http://pastebin.com/seySfpku

Pedantry aside... are you really going to defend Javascript's core method of function handling as good design by using the C function pointer as an example?

On some level, defending JS using C is like saying you can also make a souffle by instead cooking the chicken with the egg still inside it. Both JS and its bad paradigms came from C. You don't arrive at good design by showing that other people also got it wrong.

Re: Nerdsniping: A glimpse into a stubborn mind

#59
Might not be Java but still interesting, it made me think of one of my favorite little quirks in C++:

  #include 
  
  //Floating point model: Strict:Precise:Fast
  //Will code execute
  float a = nanf("");
  if (a == a)//S:No P:No F:Yes
      (do something);

  if (a != a)//S:Yes P:Yes F:No
      (do something);

  if (a  2.f)//S:No P:No F:Yes
      (do something);

  if (isnan(a))//S:Yes P:Yes F:Yes
      (do something);

NaN's (Not A Number) can propagate a long way through your code, possibly reaching places where they cause real problems. When dealing with input, especially networking, one should always check for NaN's. Basically the rule with NaN's is: The comparison always returns false if any NaN is involved. But as you can see; specifying the fast model throws that out of the window. (Code was otherwise unoptimized.)

In the third statement an otherwise fine check is done to make sure the value in a is sane, it doesn't get changed but its certainly not what you'd want it to be.

Whole lots of fun can be had when serving this to game servers. :D

Re: Nerdsniping: A glimpse into a stubborn mind

#60

Earlier quoted context omitted.

>"And this is why Javascript can be such an awful language." To be fair, this is breaking Javascript and that is something you could do in other languages, for instance here is a similar version for C++: http://pastebin.com/seySfpku

Pedantry aside... are you really going to defend Javascript's core method of function handling as good design by using the C function pointer as an example? On some level, defending JS using C is like saying you can also make a souffle by instead cooking the chicken with the egg still inside it. Both JS and its bad paradigms came from C. You don't arrive at good design by showing that other people also got it wrong.

I think you are missing my higher point. I am not defending JS or C++ for that matter (please note that I was not using C), but the fact that giving enough time you can break most languages to do something silly, in which case I don't blame the tool but the people using it.
Post reply on HN