...

View Full Version : Which language is most similar to javascript?



mklein
01-03-2011, 02:31 PM
I would like to ask people's opinions as to which "offline" language is most similar to javascript? I don't program for a living, but I have been learning javascript in my spare time. I would now like to have a shot at making a desktop application, and I think it would help to choose one which is most similar, if at all possible, to javascript?

e.g. python, ruby, C#, visual basic ... I have no idea and haven't had much luck googling this

Thanks

Matt

rnd me
01-03-2011, 06:12 PM
actionscript 2 on adobe air would be the closest match that runs on the desktop.

you can actually use javascript on the desktop as well. HTA is a windows solution, while other options like google chrome apps are cross-platform. jScript is a real .NET language, closely related to javascript; adding strong types, the .NET class library, and other qualities like compilation to EXEs.

in pure syntax, much javascript looks like PHP, C, or java. It actually behaves more like LISP, which nobody uses to build desktop apps.

Personally, i would write it in javascript if possible, which is really where everything is heading under the banner of "HTML5".
Computers coming out later this year wont even have a desktop: the only apps will be HTML5; plan ahead.

Old Pedant
01-03-2011, 09:28 PM
The only problem with using JavaScript under Windows Script Host (which effectively *DOES* make it a desktop application) is the lack of a GUI interface. You can create popups that basically ask very simple questions, but you can't create full <form>s as you can with HTML+JS. So unless your desktop application needs only a very, very simple human interface, you will need something more the JavaScript, alone.

Dormilich
01-03-2011, 11:28 PM
I would like to ask people's opinions as to which "offline" language is most similar to javascript?
I wouldn’t consider JavaScript an "online" language to begin with …

Old Pedant
01-04-2011, 12:14 AM
I wouldn’t consider JavaScript an "online" language to begin with …

An interesting viewpoint. What languages WOULD you consider to be "online" languages, then???

Seems to me, if you reject JavaScript for that role, you almost have to reject HTML, also.

siberia-man
01-04-2011, 12:22 AM
I'd like to add some words from my side to this topic. It looks very interesting for me.

First of all. JavaScript is one of the family of languages of ECMAScript - JavaScript, JScript, JScript.NET, ActionScript. The main specification for all these languages is ECMA-262. And all these languages can be considered as extensions of the parent specification.

In the other hand. Each language has some features that can be found in other languages that differ in the first look but very close in the second one. The next sentence can be fantastic but it is true. JavaScript is closer to Perl language. Below are some arguments:

1. Both of them use || and && operators in logical statements and assignments. People having experinece in JavaScript programming ofen meet the code looks like below:


// this code returns the actual value of the hash.key if key is present in the object and undefined otherwise
var hash;
var value = hash && hash.key;

// this code returns var1 if it is defined or var2 otherwise
var value = var1 || var2;


2. Each variable in JavaScript is an object and each object is a hash.


var n = 10;
alert(n.toString());

var s = 'string';
alert(s.toString());

// difference is in declaration syntax only (: instead Perl's =>)
var o = {
key1: 'value1',
key2: 10
};


3. Regular expressions in JavaScript are embeded features of the language like in Perl. They are not foreign string presentaions of regular expressions like in Java or PHP. Compare this:


# Perl
my $re = /\d+/;

// JavaScript
var re = /\d+/;

// PHP
$re = '/\d+/';


4. Like Perl, JavaScript uses closures actively


var func = function(a)
{
return function(b)
{
return a + b;
};
};

var add10 = func(10);
var x = add10(5);

Dormilich
01-04-2011, 12:27 AM
An interesting viewpoint. What languages WOULD you consider to be "online" languages, then???
any language (exclusively*) running on a server.
… and therefore requires an internet connection (http, udp, tcp/ip, etc.)

* - most of the time. you can run PHP through CLI and you can have server-side JavaScript, although both cases ain’t used much.


Seems to me, if you reject JavaScript for that role, you almost have to reject HTML, also.
indeed. for the browser it doesn’t matter whether the HTML source code comes from a web server or the local hard drive.

@siberia-man:
regarding 2.: nearly every variable is an object. null & undefined are primitives and the string/boolean/number literals ain’t true objects either, although they can be converted to objects.

var x = "some string";
// every JavaScript object inherits from Object
alert(x instanceof Object); // false

siberia-man
01-04-2011, 12:36 AM
Old Pedant,
Dormilich,

You forget HTA (Hyper Text Applications) in Windows world. HTAs can be considered as GUI applications by using HTML+JScript+CSS. In the other hand, XUL is the alternative view of HTAs at Mozilla.

Dormilich
01-04-2011, 12:42 AM
what does this have to do with "online" languages?

Old Pedant
01-04-2011, 12:46 AM
Okay, Dormilich. Your definition of "online" is different than the one rndme and I were thinking of, obviously, but given your definition I quite agree.

*******

As a minor point:
the string/boolean/number literals ain’t true objects either, although they can be converted to objects.
True. And it's important to note that the conversion can be, and often is, implicit and automatic. As when you code (3.14159265).toFixed(2), just to pick a simple example.

Dormilich
01-04-2011, 01:02 AM
Okay, Dormilich. Your definition of "online" is different than the one rndme and I were thinking of, obviously, but given your definition I quite agree.
it is always a question of the definition. be unclear about that and confusion is unavoidable.

DJCMBear
01-04-2011, 01:36 AM
I would say JavaScript, (X)HTML(5), XML basicly anything that can be used on the local hard disk is an offline language (Definition: offline meaning no internet connection or localhost server) as all the codes that still run when there is an internet connection or not can run offline.

Online (Definition: online meaning internet connection or localhost server) are such languages which need a server of some sort to be able to render the code the right way with codes like PHP if opening a PHP file offline the browser will do one of two things, 1. it will try and download the file or 2. it will just display all of the PHP codes as source code. Running the online codes on a server will allow the parsers to parse the codes and return the rightful output. Hence the sayings Server-Side and Client-Side.

johnmerlino
01-04-2011, 02:33 AM
JavaScript is written in C, so for desktop publishing, I would use C as a substitute for JavaScript, as it has its own event-driven model. JavaScript also has a lot of similarities with Java as far as comparing a dynamic, weakly typed language with strong typed language goes. But to your point in terms of likeness, as wikipedia says:

"The key design principles within JavaScript are taken from the Self and Scheme programming languages."

Old Pedant
01-04-2011, 06:00 AM
> JavaScript is written in C

Not the versions I have seen source code for. They (3 of them) were written in C++.

But I don't see what that has to do with whether you could/should use JavaScript (or JScript or EcmaScript or whatever you want to call it) in an offline manner.

Heck, VB.NET was written in C++. And so were at least some dialects of various languages. And I know at least two version of Java (yes, I mean Java, not JavaScript) that were at least originally written in C++ (though one was later ported to Java, to make it self-compiling).

I don't see how the systems language that a consumer language was written in should have any bearing on this subject.

mklein
01-04-2011, 06:41 PM
Thank you for all the replies. Sorry I wasn't able to check back in a while.

A lot of interesting replies. In conclusion it seems, from the range of replies, that there may not be one single language which could be considered most similar.

However many thanks in particular to siberia-man and your perl examples. I wouldn't have guessed that this language could be so similar. I will read up some more on that and see if it may be suitable for the types of app I would like to make.

Thanks again

Matt



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum