Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"JavaScript [...] has relatively trivial syntax"

Really? At one point I was looking into using a linter program in my Intro-To-Programming-With-JavaScript and then realized that it didn't really catch any syntax errors because there were so few.

For example - you might call a function like this:

x = myFunction();

But what if you leave off the (), which is an easy to make, beginner/novice type mistake. Then you get this, _which is still valid JS_:

x = myFunction;

What if you leave out parameters that your function needs? What if you include extra parameters? What if the parameter types that you're expecting don't line up with ones that are provided (perhaps because you left out / added in an argument?)?

On the one hand I get it - JS is a loosely typed language so it doesn't do a lot of syntax checking at code-writing-time/"compile-time"/linting-time, but on the other hand there is a _ton_ of easy to make novice errors that are actually valid JS code.

I'm not saying that Python is a better choice for beginners, I'm just not convinced that JS's relative lack of syntax-based limits is a great choice either :)



Which linter were you using? ESLint/etc doesn't catch errors like that, you need Typescript (which can work on plain JS files as a linter).

On the other hand, your example is valid Typescript, although if you use attempt `x + 1` then Typescript will yell at you for incompatible types.

Unfortunately your example is also a problem in Python, if not worse:

    def foo() -> int:
        return 42

    # valid
    x: int = foo()

    # also valid
    x: int = foo
Why is this valid?! Well, Python doesn't actually check your type annotations, you have to choose and use a type-checker (example: mypy). There is no default type checker for Python, and invalid types are silently ignored by the interpreter.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: