To the question of programming languages ​​...

    Since voting does not allow you to leave comments, I will draw up comments as a separate article.

    Of particular interest is the opinion of people who believe that this cannot happen to them (the penultimate item in the survey). Why?

    Under the cut - a complete example in one of the common programming languages. Bonus! Not even one programming language, but two.

    JavaScript: PHP (example corrected , thanks Sannis ): What other languages ​​that allow this, do you know and do you think that the convenience provided by this approach justifies the problems that it creates?
    function remove_element(/* array */ a, /* element */ e) {
      var b=[];
      for (var i=0;i     if (a[i]!=e) b.push(a[i]);
      }
      return b;
    }
    var before=[7, "13", "5", 6];
    var after=remove_element(before, "13");



    function remove_element(/* array */ $a, /* element */ $e) {
      $b=array();
      foreach($a as $m) {
        if ($m!=$e) array_push($b, $m);
      }
      return $b;
    }
    $before=array("11", "a", 2, 3);
    $after=remove_element($before, "a");



    PS Many programming languages ​​have a lot of oddities when dealing with floating-point numbers - but this is well known and can be protected with a maximum of half a point. Although, even if I attract floating-point numbers in sane programming languages ​​(C / C ++, Java, Python, Lisp) I can’t think of anything (without overlapping operators, which, of course, is pure cheating).

    PPS In general, the whole topic grew out of a discussion where they tried to explain to me that I do not understand anything in programming and my unwillingness to put up with similar, so to speak, programming languages ​​testifies to my dullness and wretchedness, and not about problems in the language.

    Also popular now: