Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this questionJust a quick query ...
I would like to ask people's opinions as to which 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 cho开发者_如何学Cose 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
Why not use Javascript? Who says it can be used only for "online" programs?
There's a Windows Script Host on Windows that allows you to run Javascript programs from the command line or double-clicking in Explorer.
Other OS's have similar script engines.
It depends on what you mean by "similar". Syntactically, JavaScript is part of the syntax tradition derived from the B programming language (C, C++, Java, and C# are others in this syntactic tradition). But that's just syntax. JavaScript isn't much like those (although both C# and, to a lesser extent Java, are getting more and more "functional" features added to them). If you're writing for Windows, you might take a good look at C# (and a subset of it is supported on Linux, in the form of the excellent Mono project).
You might look at JScript.Net, which is a language for the .Net platform that's, well, I'll say inspired by JavaScript. Again, that's a bit Windows-ish although (again) Mono provides a good layer for Linux.
Visual Basic (.Net or otherwise) will not be a good fit. Fairly easy syntax (BASIC was designed for easy syntax), but not very much like JavaScript.
If you don't mind a syntactic departure, both Ruby and Python are dynamic languages like JavaScript, and both are fairly popular these days for desktop apps (at least on Linux).
You certainly could use JavaScript if you want to. Someone else mentioned Adobe AIR, but I'll throw out another one: Rhino, which is JavaScript for Java. That gives you access to the huge collection of Java libraries out there (as the JavaScript code can interact with Java code and vice-versa). Whether you want to do a desktop app using Java technology (even though writing JavaScript) is obviously going to be up to you.
For command-line apps, you can use V8 directly, or NodeJS which uses V8 but has a lot more (and on Windows, JScript with Windows Scripting Host).
You can use Adobe Air to run Javascript + HTML + CSS.
Although JavaScript can be used offline, I wouldn't use it unless I had to. The choice of language depends on what you want to write. If you want to write GUI applications for Windows, C# is a much better choice. If you want to write scripts for data analysis etc, there are good languages for that, like python.
If you're looking to create Desktop applications with little-to-no experience, it may be better going for an Express edition of Visual Studio, which comes in Visual Basic, C# and other flavours. You can create both desktop and web applications for free.
C#, C++, Java and JavaScript share a lot of syntactically similar language features; braces etc. You'll hopefully find once you get used to the syntax is easier to transition to another language too.
Believe it or not, but one language that is very similiar to Javascript (although not syntactically) is Scheme. Take a look at this article by Douglas Crockford. It might not provide you out of the box tools for making fancy desktop applications, but it is a good language for learning important programming idioms.
And let's not forget JScript.NET!
(even if everybody else did).
Edit - another option for the .NET and Mono frameworks (and somewhat unknown to standard, non-game programmers) is UnityScript (but I don't even know if you may use it outside of the Unity 3 development environment). Seems to be JavaScript with classes and inferred static typing (maybe similar to ActionScript).
Thank you for all the extensive replies. Sorry I was not able to check back sooner.
So as a sort of conclusion it was wrong of me to assume I cannot make desktop apps using javascript. Actually, shortly after posting my original question I stumbled across AIR myself. However, and correct me if I wrong, it all seems a bit "bloated" (hot air ?). To deploy it on some other maching it will require AIR to already be installed? Indeed, it would download as a .air file, and I don't think there is a way to make an executable. Some other, more knowledgable people also listed many of its limitations on another site.
I also investigated Rhino (thank you Crowder). However I could not find much of an explanation on the Mozilla site of how I could use it by just scripting in javascript? The example they offer for download was full of java code ! ?
Anyway, it seems at least that it is possible to make a .exe which can run in the console for, say, simple number crunching. I will have a go at this. I suspect that things will get more tricky if I want to make some sort of GUI.
Thanks again for all the excellent replies
Matt
精彩评论