Hacker News new | ask | show | jobs
by calibas 2029 days ago
This is all semantics, but the idea was that Java is a "real" language for serious use and JavaScript is a "script" that's much easier to use and doesn't involve all the complications of a "real" programming language.

It was only kind of true back then, and not even remotely true now. There really isn't a solid line you can draw between a "script" and a "programming language". To me, something like Python is right in between.

3 comments

I feel like "requires compilation" is a good first order differentiator. And "has a somewhat sane type system" is another.
TypeScript requires compilation and has a rich type system. It also has "script" in the name.

I think "scripting" vs "programming" language differentiation is elitist nonsense. This isn't a meaningful boundary. It's more useful to speak of languages in terms of strong/duck/loose typing, syntax, supported programming paradigms, ecosystems, available libraries and tooling, and intended use cases.

Well, C++ can be interpreted (sort of, see CINT) and can certainly be semi-transparently jitted (see cling). Although it's certainly not designed for that!
C# 9 added “top level statements” which seems to be the first steps towards usage in a script environment.

https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh...

Templates are turing complete and universally interpreted AFAIK (I don't think any implementation compiles them before evaluation?). There's also features like constexpr these days.
tcc is fast enough to run C code (or langs targeting C) as scripts.
> There really isn't a solid line you can draw between a "script" and a "programming language"

I think it's easier to draw the line if you have the requirements right. That's not the line that was being drawn. it was scripting vs compiled languages. It was very clear then which sides Java and Javascript fell on. There are some weird cases now like compiling scripts into different scripts, but in general it's pretty clear, and Python is definitely a scripting language.

The great "script vs programming language debate". The difference is clear to you because you have a clear definition in your mind. The problem is that the definition changes depending on who you talk to, which invites endless debate.
Well it's a pretty bad debate if people aren't agreeing on definitions. Hence this whole chain of comments.
Basing the definition on whether it's compiled or not doesn't help much.

Python is actually compiled to bytecode, just like Java. Is it not a scripting language?

Or is the distinction that the Python bytecode is interpreted whereas Java is JIT compiled to machine code? Well, Java didn't get the JIT compiler until version 1.3 - so was Java 1.2 a scripting language?

The distinction is the existence, from the developer’s perspective, of a separate step called “compilation,” which produces an executable artefact which can be distributed but not converted back to the source code. It’s about programming in practice, not fundamental computer science principles.
I agree, this practical view makes more sense. However, the Kotlin compiler can be invoked either explicitly like Java or implicitly like Python. Is Kotlin a scripting language?
To me, if something acts logically like it is run from top to bottom, it's a scripting language. Python scripts and JavaScript are in this category; Java isn't.

Additionally, explicit compilation/linking/assembly shouldn't be required for a scripting language, even if the interpreter does stuff kind of like this behind the scenes for performance.

That makes Ocaml and Haskel into scripting languages.
You can't just put `putStrLn "Hello"` in the top level of a Haskell program and expect it to work. You can do it in a REPL, but that's besides the point.
Sure. I was responding to this:

“To me, if something acts logically like it is run from top to bottom, it's a scripting language.”

I don’t see them as scripting languages, but that definition would include them.

And my point is that Haskell doesn't even look like it's run from top to bottom.

Example, consider this mutually recursive definition at the top level:

    a = 1:b
    b = 2:a
It doesn't, by any means logical or not, look like it runs from top to bottom. If so, the first line would have immediately been an error because `b` is an undefined name.
My mistake - I thought Haskell was like OCaml in not having a main function:

http://stackoverflow.com/questions/28711563/ddg#28711778

You broadly dismissed my entire comment, which was completely correct about Ocaml, but I accept that you are correct about Haskell.