Quote:
|
Originally Posted by georgev
Then along comes some C# stuff - I've had a google or three at some examples and it seems to be rediculously similar syntax to JavaScript - fair assumption?
|
I haven't used Java since a few releases, but I'm pretty familiar with it. The same is true for Javascript. I haven't done nearly as much with C#. Javascript is more properly known as ECMAScript, and aside from syntactic similarities, is not based on Java and is completely incompatible with Java. The Netscape folks called it Javascript for marketing reasons and I never did understand why Sun didn't sue them. Actionscript, which is in Flash, is also based on ECMAScript. JScript is MS's implementation of Javascript.
Synopsis: Javascript was designed for simple programming. It's become pretty big, I believe there's some startup named Google that has a bunch of stuff that's endlessly in beta. Java is a "serious" programming language that brought 10 year old OOP ideas into vogue. It's designed to always do the right thing and be highly consistent so you have to write endless error checks and type conversions, though I hear they've fixed this somewhat. C# was set up explicitly to destroy Java so it has lots of nice things for developers and tries to give you what you want.
Syntax: yes, they're all based on C which inherited it from earlier languages. There are little differences. Javascript has the simplest, Java has the most uniform, C# is like Java but more flexible.
Imperative control structures: all have the usual for, while, foreach, try/catch, if.
Subroutines: You can pass a subroutine as a value in each language. C# has delegates which I find a little weird. None of them support coroutines, to my knowledge.
Simple data types: all have various integers, floats, a boolean, strings. But Javascript ignores all that, so a string that happens to say 15 behaves like the number. The other languages make you do this manually.
Declaring variables: Javascript doesn't require that you declare variables.
I don't think any of them allow global variables; you have to assign a variable to a class (this is an OOP concept).
Object orientation: They all do it. Javascript has supported prototypes (a different way of doing OOP than Java and C#) as early as Netscape Navigator 2.
Complex data types: Mostly done through objects. Java and C# both have a root Object class that everything is a "subclass" of. Java goes with the "everything is an object" philosophy as much as possible. C# has special structs for user-defined types. Both have arrays; C# has more features for their arrays. Java has a very extensive and mature library for working with trees and maps and other advanced objects. C# generally has better primitives, e.g. multidimensional arrays. Javascript used to be very primitive in this regard but with modern browsers depending on Javascript I'll bet that's changed.
Multithreading: Java's is based on monitors and mutexes. Javascript doesn't directly allow multithreading, to my knowledge. I haven't used C# to do any multithreading.
Multitasking: I'm quite sure none of them support fork, which is a pity. Unix guys will harrumph about this.
Supporting libraries: All of them have massive APIs that virtually implement an operating system.
Memory management: they all use garbage collection, and all of them use a pretty sophisiticated system.
Mode of execution: Java semi-compiles to bytecode which is run by the infamous Java Virtual Machine. C# compiles to bytecode that is run by the Common Language Runtime. Javascript is also compiled, but the browser generally does it behind the scenes.
I/O: Javascript generally runs in a browser or flash plugin or something. Nowadays you can send AJAX requests, so the sandbox you play in is a little bit bigger. If you don't mind warning dialogs and paying ridiculous fees to certificate authorities, you can get local file access. Java and C# both have excellent IO systems that are highly adaptive and customizable.
GUI: .NET's WinForms is uninspired, but I guess it works. Java has gone through several iterations trying to find the ultimate UI that works on anything, and it still generally sucks, but see Eclipse and jEdit for counterexamples. Javascript sticks you with the usual horrible browser UI.
Database: Java has JDBC. The latest revisions of C# supposedly allow SQL directly in the source code. With Javascript, you're stuck sending AJAX requests back to the server.