Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which language is most similar to javascript?

    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

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 584 Times in 565 Posts
    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.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by mklein View Post
    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 …
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    Quote Originally Posted by Dormilich View Post
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Regular Coder
    Join Date
    Sep 2010
    Location
    Far far away
    Posts
    122
    Thanks
    0
    Thanked 16 Times in 16 Posts
    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:
    Code:
    // 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.
    Code:
    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:
    Code:
    # Perl
    my $re = /\d+/;
    
    // JavaScript
    var re = /\d+/;
    
    // PHP
    $re = '/\d+/';
    4. Like Perl, JavaScript uses closures actively
    Code:
    var func = function(a)
    {
        return function(b)
        {
            return a + b;
        };
    };
    
    var add10 = func(10);
    var x = add10(5);

  • #7
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by Old Pedant View Post
    An interesting viewpoint. What languages WOULD you consider to be "online" languages, then???
    any language (exclusively*) running on a server.
    Edit: … 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.

    Quote Originally Posted by Old Pedant View Post
    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.
    PHP Code:
    var "some string";
    // every JavaScript object inherits from Object
    alert(instanceof Object); // false 
    Last edited by Dormilich; 01-04-2011 at 01:00 AM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #8
    Regular Coder
    Join Date
    Sep 2010
    Location
    Far far away
    Posts
    122
    Thanks
    0
    Thanked 16 Times in 16 Posts
    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.

  • #9
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    what does this have to do with "online" languages?
    Last edited by Dormilich; 01-04-2011 at 12:44 AM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by Old Pedant View Post
    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.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #12
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    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.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #13
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts
    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."

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    > 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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #15
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •