LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-17-2012, 07:21 PM   #1
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
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).
 
Old 11-18-2012, 12:03 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 11-18-2012, 11:35 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Original Poster
Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by graemef View Post
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.
 
Old 11-19-2012, 03:59 AM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 634

Rep: Reputation: 139Reputation: 139
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

Last edited by AnanthaP; 11-19-2012 at 04:24 AM.
 
Old 11-19-2012, 06:59 AM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,381

Rep: Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109
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.

Last edited by sundialsvcs; 11-19-2012 at 07:01 AM.
 
Old 11-19-2012, 01:11 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Original Poster
Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by AnanthaP View Post
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.
 
Old 11-19-2012, 01:13 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Original Poster
Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by sundialsvcs View Post
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.

Last edited by Sergei Steshenko; 11-19-2012 at 01:15 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Open Source Boosted By Recession And Maturity LXer Syndicated Linux News 0 07-31-2009 02:41 PM
LXer: Banshee 1.2 - Getting to Maturity LXer Syndicated Linux News 0 08-12-2008 08:11 PM


All times are GMT -5. The time now is 11:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration