LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Maturity of JavaScript in general (http://www.linuxquestions.org/questions/programming-9/maturity-of-javascript-in-general-4175437622/)

Sergei Steshenko 11-17-2012 08:21 PM

Maturity of JavaScript in general
 
Hello, I am looking at JavaScript from the point of view of what I know in Perl (and "C" for that matter).

For example, it appears that it's not that easy to get current line number in JavaScript, e.g. http://stackoverflow.com/questions/2...-in-javascript .

In Perl/"C" there is simply __LINE__.

And I am even afraid to ask about JavaScript equivalent of Perl 'warn' (print to stderr with current file name and line number).

Aren't these features obviously needed ? Why aren't they readily available in a language that's been around for more than a decade ? Especially taking into account they exist in Perl and other languages and according to WikiPedia JavaScript was influenced by Perl (as I'm looking into it I agree with the statement).

graemef 11-18-2012 01:03 AM

Quote:

Originally Posted by Sergei Steshenko (Post 4831682)
Aren't these features obviously needed ?

Obviously not.

I'm sure that their are arguments for being able to know the line number but usually the only time I require something like that is when I'm debugging and then I would use a debugger - firebug being my choice of poison. Whilst I know that Javascript is used in more areas beyond web-programming that is it's original purpose and with the use of optimisation compilers such as Google's closure the concept of a line number is removed when the optimised script is run.

Sergei Steshenko 11-18-2012 12:35 PM

Quote:

Originally Posted by graemef (Post 4831784)
Obviously not.

...when I'm debugging and then I would use a debugger - firebug being my choice of poison. Whilst I know that Javascript is used in more areas beyond web-programming that is it's original purpose and with the use of optimisation compilers such as Google's closure the concept of a line number is removed when the optimised script is run.


I don't like debuggers in general - I much prefer debugging through print to stderr statements or one can put it differently - through logging. Or even more differently - through controlled tracing.

...

I remember a case in an implementation of SystemVerilog - a piece of code with diagnostic 'print' statements worked differently (and correctly) than the same piece of code with the statements commented out.

...

Apparently, we are in the age of new normalcy, and I too old to adapt.

AnanthaP 11-19-2012 04:59 AM

Quote:

I remember a case in an implementation of SystemVerilog - a piece of code with diagnostic 'print' statements worked differently (and correctly) than the same piece of code with the statements commented out.
Possibly it acts like an "fflush".

I think that in part at least it has to do with the fact that for at least the first half decade of it's existence, it was seen primarily as a front-end scripting language. Of course, in this scenario, you could always set the BROWSER to display the error line and so didn't need any specific feature of JAVASCRIPT to have an error line number -or any line number by inducing a wrong syntax or something. Also after some time NETSCAPE died out even as Microsoft was pushing their own vbs as an ubiquitous standard for every scripting need.

OK

sundialsvcs 11-19-2012 07:59 AM

Remember also that "line numbers" might or might not have an easily-usable meaning in the situations where JS is most commonly used: as downloaded scripts in web-pages. Very sophisticated on-line debuggers are readily available and are far more suitable for directly locating and resolving a problem. If a feature seems to be "missing," it's probably because the language designers didn't deem it to be so important to them in this particular language project. And, it would seem, so far no one else did, either.

The C/C++ languages, recall, use a two-step compile/execute deployment process; JS does not. Programs in trouble that were written in C/C++ might not be running under a debugger; JS programs easily could be. There are quite a few differences between the two languages that stem from such pragmatic considerations.

Sergei Steshenko 11-19-2012 02:11 PM

Quote:

Originally Posted by AnanthaP (Post 4832433)
Possibly it acts like an "fflush".
...

No, it was a plain bug - among many others. I.e. optimization was screwing up, and 'print' statements were disabling optimization.

Sergei Steshenko 11-19-2012 02:13 PM

Quote:

Originally Posted by sundialsvcs (Post 4832532)
Remember also that "line numbers" might or might not have an easily-usable meaning in the situations where JS is most commonly used: as downloaded scripts in web-pages. Very sophisticated on-line debuggers are readily available and are far more suitable for directly locating and resolving a problem. If a feature seems to be "missing," it's probably because the language designers didn't deem it to be so important to them in this particular language project. And, it would seem, so far no one else did, either.

The C/C++ languages, recall, use a two-step compile/execute deployment process; JS does not. Programs in trouble that were written in C/C++ might not be running under a debugger; JS programs easily could be. There are quite a few differences between the two languages that stem from such pragmatic considerations.

And I am looking at JS in Qt QML and in Google V8 engine - as a general purpose not at all necessarily browser-hosted language.


All times are GMT -5. The time now is 07:21 AM.