News for hackers. Stuff that matters.
Re:JavaScript is Eating the World by mschuetz on Thursday August 24, 2017 @09:43AM (#15090020)
With ES6, JS became a really nice scripting language. Personally, I'm glad to see more and more projects that use javascript outside of web browsers and I've also added V8 to my most recent C++ project. The only major drawback in my opinion is, that it's not statically typed.
Re:JavaScript is Eating the World by flavio81 on Thursday August 24, 2017 @10:53AM (#15090561)
The deeper problem is that JS is not strongly typed. Typescript gives you static type checks but the runtime is still weakly typed and will still do all sorts of weird type conversions.
Re:JavaScript is Eating the World by monsieurbanana on Thursday August 24, 2017 @11:19AM (#15090801)
Theoretically, to what extend could the weird type conversions be prevented with the use of a strict linter? My intuition would be all, but I haven't thought much about it.
Re:JavaScript is Eating the World by flavio81 on Thursday August 24, 2017 @11:40AM (#15090992)
Once code reaches a certain complexity level (and mind you, the threshold is rather low), you'll need dynamic generation of code and data (or else, write 10x the amount of lines of code). For this to happen in a safe way, you really, really, do need the runtime to be strictly typed.
Re:JavaScript is Eating the World by 0xffff2 on Thursday August 24, 2017 @01:12PM (#15091957)
Are you making this claim about JavaScript or as a general statement? I've probably written less than 1000 lines of JS ever (and that only for hobby projects), but I would strongly disagree with this statement as applied to C++, Java, etc.
Re:JavaScript is Eating the World by thehardsphere on Thursday August 24, 2017 @02:45PM (#15092830)
I'm sorry, I'm confused by the way you expressed that. The argument was you need strict typing for large projects. C++ and Java have strict typing. What exactly is the basis of your strong disagreement?
Re:JavaScript is Eating the World by flavio81 on Thursday August 24, 2017 @08:14PM (#15095142)
My comment is applied to any language with weak typing. Example: Javascript, PHP, and (sadly) C, particularly when using pointers to void. However, in C it's okay since there are big performance gains when you have full control of the memory.
Re:JavaScript is Eating the World by mschuetz on Thursday August 24, 2017 @12:14PM (#15091344)
Strong typing is a start but not enough for my taste. Static typing serves as documentation and compile time bug check, which is awesome to have. I'd like to have both, without the detour over typescript.
Re:JavaScript is Eating the World by seanwilson on Thursday August 24, 2017 @12:50PM (#15091732)
I don't think you're going to get strong types in standard JavaScript any time soon. Isn't TypeScript a very good compromise right now?
Re:JavaScript is Eating the World by flavio81 on Thursday August 24, 2017 @08:15PM (#15095148)
My take is that having dynamic typing plus strong typing is a (pretty) good compromise. And static typing plus weak typing, insufficient.
Re:JavaScript is Eating the World by seanwilson on Thursday August 24, 2017 @08:50PM (#15095309)
What languages would you put in these two categories?
Re:JavaScript is Eating the World by flavio81 on Friday August 25, 2017 @12:06AM (#15096042)
Not all languages but here's a list:

dynamic typing, strong typing: python (for the most part), Scheme

dynamic typing, weak typing: Javascript, PHP

static typing, strong typing: Pascal, Ada, Java, C#

static typing, weak typing: C, Typescript, perhaps others

SPECIAL CASES:

strongly typed, dynamically typed, but with some compilers it can also be statically typed: Common Lisp

strongly typed, statically typed but can infer types: Haskell, ML family

strongly typed, can infer type with "auto" keyword: C++ (latest version)

non-typed: Machine language, assembler, perhaps Forth

Re:JavaScript is Eating the World by seanwilson on Friday August 25, 2017 @01:02AM (#15096236)
What better alternative do you have to TypeScript right now though that you can use practically with existing libraries? Perfect is the enemy of good. TypeScript can capture more complex properties than C as well.
Re:JavaScript is Eating the World by gmac on Thursday August 24, 2017 @09:47AM (#15090056)
I agree. On the whole, I think JS is a middlingly-nice language. It has some good bits and some bad bits. ES6 brings a whole lot more good bits.

I sometimes think we could do with a bit more thanking-our-lucky-stars that the language that got entrenched on the web wasn't, say, VBScript (which IE did use to support).

For your major drawback, there's TypeScript.

Re:JavaScript is Eating the World by nerdwaller on Thursday August 24, 2017 @09:50AM (#15090078)
The real issue with js (node) as a "scripting language" is the lack of a stdlib. A nice thing about writing a Python script is you know the stdlib is there on your remote machine (since some version of Python is on most systems by default other than windows).
Re:JavaScript is Eating the World by randiantech on Thursday August 24, 2017 @09:46AM (#15090043)
Indeed, although Typescript is a good solution to have more OOP based abstractions, like Generics, Abstract Classes and Interfaces.