back to article When it comes to ML, reports of JavaScript's death are exaggerated

Machine learning is fast becoming one of the high-growth areas for developers – but what language should you employ, given that so many exist? If you believe the statisticians, Python is the default choice for many. 50 per cent of data scientists and developers use Python, with 33 per cent prioritising it for development, …

  1. Robert Grant

    No.

    This article is silly, on a couple of main counts:

    1) saying "Javascript is still useful for non-ML stuff you might want to do" is not an argument for using Javascript with ML.

    2) There's a bit of a self-fulfilling prophecy here. "Why is Python massive?" asks Purves. "It's because there's a massive Python library. It will be hard to dislodge the ecosystem." - wrong. A self-fulfilling prophecy would be if people were using Python because it's known to be massive, which is undoubtedly true, but not what's claimed here.

    3) Why do you want to push Javascript here? Why not any other of a number of languages for whom the exact same vague arguments apply?

    1. Anonymous Coward
      Anonymous Coward

      Re: No.

      Indeed. Re Python's popularity, especially in the sciences - I think it's because it has relatively few paradigms you need to understand, making it relatively easy to learn to the extent that you can get something working. There's always a trade-off between development time and run-time.

  2. HmmmYes Silver badge

    Javascript is terrible. No other words.

    I have to live with writing Javascript to run on the client/browser. And thats were it will still stay.

    As far as ML goes, its less one language, more that you have a high level pyhton wrapper around a lot of c libraries doing the crunching.

    1. Anonymous Coward
      Anonymous Coward

      you have a high level ... wrapper

      This.

      People will use whatever language they are used to. Python is (for most) easier to learn (or copy from stackoverflow) than R, so it is more used.

      "Has it been left behind by the Python revolution?" will make some sense when ALL uses of JavaScript are affected. Just say no to the "one language to rule them all" sillyness.

    2. el kabong

      There's nothing terrible in JavaScript, nothing at all. Only someone who's falling behind will think there is.

      1. el kabong

        I'm always amazed by the rapid fire of emotional negative reactions I manage to get just by pointing out a few simple undeniable truths.

        1. sabroni Silver badge

          there's nothing terrible in javascript

          Sorry, but if I can write:

          if (a == b) and get true and

          if (b == a) and get false then that is terrible.

          Of course, as any fule no, if (a === b) then (b === a), so the language is definitely usable. In fact I love a bit of JavaScript. But all languages have terrible bits, the trick to being a good engineer is knowing what to avoid. (The == behaviour can be useful if you know it'll co-erce to the type of the left hand thing.)

          Still, all the knee jerk "javascript is terrible" comments are stupid. It's a language, a very powerful language when used correctly. Learn to use it correctly.

          The problem is that people who think it's terrible write terrible code, then go "look, this is terrible!" without any sense of irony.

      2. Charlie Clark Silver badge
        Facepalm

        There's nothing terrible in JavaScript, nothing at all.

        There have always been problems with JavaScript. Hardly surprising for something that was cooked up as quickly as it was. More surprising perhaps, is how far it has managed to get despite these limitations.

        But the writing for ECMAScript is on the wall: Web Assembly. Most core JS developers, those that work on the language, seem to agree that they've come about as far as they can with it without a major rewrite and if you're going to rewrite a programming language…

  3. Anomynous Curd

    Given that JavaScript is so numerically illiterate it allows you to perform a subtraction between a string and an integer without raising an error I cannot possibly fathom how painful using it for statistical and analytics work would be.

    1. MonkeyJuice

      "I cannot possibly fathom how painful using it for statistical and analytics work would be"

      "My god, it's full of NaNs."

      1. el kabong
        Devil

        Re: "I cannot possibly fathom how painful using it for statistical and analytics work would be"

        And curly braces too. Awful awful awful!

    2. sabroni Silver badge

      it allows you to perform a subtraction between a string and an integer without raising an error

      The engineer who wrote the code that did that comparison, in the knowledge that JavaScript will just co-erce the types until it can do what it's asked to, and then complains about it, is not a good engineer.

      If you're string contained "40" and your number was 2 and the answer returned was the number 38, what's your problem?

      1. Anonymous Coward
        Anonymous Coward

        Re: it allows you to perform a subtraction between a string and an integer without raising an error

        "in the knowledge that JavaScript will just co-erce the types until it can do what it's asked to"

        Oh, I have no problem with type coercion. It can be a good thing, especially in exploratory/analytical workloads. It's one of the key reasons Python is so popular in this space.

        JS's problem is the type coercion/method overloading is illogical *and* inconsistent. To extend on the example

        "1" + 1 = "11" i.e. the concatenation of the string representation of the integer 1, based on order-of-operations. Alright, fair enough, a bunch of languages will do this.

        "1" - 1 = NaN i.e. a string plus an integer is a NaN because this language is insane.

        Or how about. Array+Array = "". Well, you can just about see that. But hang on a second..

        []+{}={}. An array plus object is an object? Well, again, kind of makes some sort of sense. What about {}+[]? Bloody zero. It adds up to bloody zero. Lunatic language.

      2. a_yank_lurker Silver badge

        Re: it allows you to perform a subtraction between a string and an integer without raising an error

        If the variable accidentally hold a value that can be coerced to an integer this could be disastrous.

    3. Jason Bloomberg Silver badge

      Every language has something which some will call 'so insane' that it rules out using it for them.

      Automatically creating a local variable when I have forgotten to specify that as 'global' or have typed a variable name wrongly has driven me nuts using Python. "Syntax error" in a line other than the one the error is actually in has had me scratching my head at times. Some people truly hate Python's rigid indentation rules or other peculiarities of syntax.

      As Dylan put it; "And the first one now will later be last". I have lived through so many "best language" eras that I have lost track.

      1. Charlie Clark Silver badge

        Automatically creating a local variable when I have forgotten to specify that as 'global' or have typed a variable name wrongly has driven me nuts using Python.

        Sounds like your problems are more than with Python. global does exist but you will never need it. Like exec and eval it's there for a reason but the overwhelming majority of Python code will never need it.

        Whitespace or braces is personal preference but in team work whitespace is much easier to enforce.

        At a programming level Python can be criticised for dynamic typing, memory use, the global interpreter lock, speed but for any of the random inconsistencies that Javascript throws up.

        1. sabroni Silver badge

          any of the random inconsistencies that Javascript throws up.

          Proving the poster above you's point exactly. You understand Python and think it's excusable, you don't understand JavaScript so dismiss it.

          1. Charlie Clark Silver badge

            Re: any of the random inconsistencies that Javascript throws up.

            Proving the poster above you's point exactly. You understand Python and think it's excusable, you don't understand JavaScript so dismiss it.

            What do I think is excusable? Using a variable that is not in scope will raise a NameError and not a SyntaxError. If you find yourself wanting to use global in Python you're most probably doing something wrong but the language treats you like an adult and doesn't try and guess what you might mean.

            Python's scoping combined with it's mutable types can cause problems in class variables.

      2. Nolveys Silver badge
        Unhappy

        Automatically creating a local variable when I have forgotten to specify that as 'global' or have typed a variable name wrongly has driven me nuts using Python.

        I completely agree. I quite like Python, but don't understand why it doesn't insist that variables are explicitly declared.

        rectilinear_chicken_count = rectilinear_chicken_storage_x * rectilinear_chicken_storage_y

        if rectilinear_chicken_count < 0:

        ⠀⠀⠀⠀rectliinear_chicken_count = 0

        1. Charlie Clark Silver badge

          I completely agree. I quite like Python, but don't understand why it doesn't insist that variables are explicitly declared.

          Because it has strong and dynamic typing. This was a design decision related to Python's target audience of non-programmers. As a consequence there is a strong preference for descriptive variable names. Static typing is still considered relevant only for compiler optimisations.

          1. Nolveys Silver badge

            Because it has strong and dynamic typing.

            That doesn't preclude explicit declaration. A, say, "var" keyword in front of an initial assignment could tell the interpreter that a particular variable name is actually intended to exist within a scope.

        2. Anonymous IV
          Unhappy

          > ⠀rectliinear_chicken_count = 0

          What did Python say on encountering this misspelled variable name?

          No artificial intelligence in there!

  4. Disgruntled of TW
    Thumb Up

    Edinburgh Uni and Standard ML

    Giggle. Sorry. I hoped for a brief millisec or so that we were comparing the functional language "Standard ML" as created by Robin Milner and the LFCS in 1987. Somebody wrote a garbage collector for it while I was studying there ... no quiche eaters, just real programmers back in the day. Fond memories.

    1. Destroy All Monsters Silver badge

      Re: Edinburgh Uni and Standard ML

      +1 for ML.

      That language came in from the LCF theorem prover. As opposed to strolling in from the web interactive backalley hackathon. It's still good.

    2. Charlie Clark Silver badge

      Re: Edinburgh Uni and Standard ML

      And I read "Markup Language" every time I see ML. It's usually best to avoid these abbreviations wherever there is a chance for ambiguity. But journalism 101 says in any case that you should define the abbreviation at the first use in a text. Sub-ed should have picked this up.

  5. SwizzleStick

    Doctor doctor, it hurst when I do this... (imagine some twisted contortion)

    Doctor: "Don't do that then"

  6. stephanh Silver badge

    Add two matrices A and B

    Python: A + B

    Javascript: math.add(A, B)

    Yes, this matters to some people.

    1. Destroy All Monsters Silver badge

      Re: Add two matrices A and B

      But you can download jQuery!

  7. Charlie Clark Silver badge
    Thumb Down

    Wrong-headed

    But where does that leave JavaScript? Like Python, it been at the forefront of web development for about 20 years

    For most of that time they've been doing very different things. And, while I'm a Python fan, I don't think it would be correct to claim Python has been at the forefront of web development at all.

    Python is more suited to machine learning than Javascript because of the eco-system and libraries that have grown up in the scientific community over the years. Python isn't great for machine learning because there are TensorFlow bindings but because there is NumPy, SciPy, Pandas, etc. Python's syntax is also very popular with the non-developer types, who've suddenly found themselves being classed as "data scientists". This combined with the extensive libraries of a general purpose language makes Python eminently suitable. Node.js simply can't compete in this area and why should it? It's great for some stuff though its existence is now threatened by the agreement of the major browser developers to support web assembly. An article on this would have been far more interesting than the collection of straw men in this article.

  8. Destroy All Monsters Silver badge
    Facepalm

    This article is a sad testament to the levels of ignorance pervasive in the industry

    There are, however, signs that not everything is quite so bleak for JavaScript and there's still room for the language. The Developer Economics research shows that developers new to data science and ML still experimenting with the technology prioritise JavaScript more than any other language.

    Seriously. "Room for the language". There is always room in the biggest chamber of randomly crazed leaking piping built in a dank cellar, financed by the Googlemonster. It's like a very special S&M dungeon.

    These people are either proudly ignorant, badly advised, too fscking lazy to learn to use an appropriate tool or just passing the time faffing around until they have to leave the warm embrace of university.

    It's reaching "gender studies" levels of sad.

    This is supposed to be SCIENCE AND ENGINEERING. NOW STOP IT!!

  9. sabroni Silver badge
    Facepalm

    re: These people are either proudly ignorant, badly advised, too fscking lazy ......

    Or they need something to run in the browser.

  10. SVV Silver badge

    My God.....

    The self driiving cars and autonomous pizza delivery drones are going to be programmed in javascript and python!!!!

    How hazardous is going outside the house going to be? If the js and python code I've seen in real production systems is anything to go by, this is a all a ruse to make us so scared to go out that we have to rely on delivery services (when they haven't crashed).

    1. Alistair Silver badge
      Windows

      Re: My God.....

      @SVV

      Well, what happened here officer is that the DevOps team updated the range detail finding calculator in the client with what was supposed to be a slight tweak to improve the accuracy and inadvertently switched from metric to ElRegStdUnits, but the firmware in the brake control system works in Imperial units, so the pizza delivery car miscalculated the stopping time and applied the brakes as it went through the front door.

  11. a_yank_lurker Silver badge

    A couple of observations

    Python has some intentional limitations from its original design (interpreted vs compiled mostly). Otherwise it is a reasonable generic, general purpose programming language. Its syntax and paradigm support makes it easy for non-programmers to learn become at least sort of competent relatively quickly. Also, it has many libraries available to do some serious having lifting. The major real problem is that Python code can be slow. Some complain about blocking by indentation when indenting in every language is consider good programming style. So Python kills to birds at once. Overall a solid language that has a wide useful range. Another language of similar capability and utility is Ruby but Ruby never got popular with scientists or engineers.

    JavaScript was not designed as a general purpose programming language but a way to add interactivity to web pages. Obviously, you need some programming constructs to do this. Its primary problem has stemmed for its initial half-baked at best initial design. Netscape did not do anyone any favors rushing it out the door as fast as they did. It suffers from a confusing mishmash of syntax and paradigm matching. It use prototypes not objects but uses conventional object oriented syntax; an annoyance. It use C like syntax when it does really derive any ideas from C (why bother?). It has a sloppy scoping system (more like poorly thought). Some are more aggravations but some make programming JS trickier than it should be. In fact there are three languages (TypeScript, Dart, and CoffeeScript) that produce JS code when 'compiled'. These languages are attempts to fix the serious deficiencies of JS. If JS is that good why are three other languages trying to fix its problems?

  12. R3sistance

    Should Javascript be replaced? Heck yes

    Should Javascript be replaced by Python? heck no.

    The language replacement for Javascript needs to be lightweight and to remove the inconsistencies caused by the various browser makers creating non-standard interpreters. In a browser you would just end out seeing the different browser makers implementing different versions of different python libraries and the entire thing becoming a mess very very quickly. Javascript has shown with it's history that such things will happen and it will just end out being a giant mess.

    Further more, Using python would make any system that dynamically generates code for the client side more complex than needs be due to python's insistence of using white space/indentation as the method of defining scope/code blocks.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019