Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript VS C#

Tags:

javascript

c#

Maybe a strange and green question, but

Is there anything C# can't do what javascript can... And considering JQuery?

except for the fact that one is clientside, and the other serverside? Or am I asking a very stupid question now?

EDIT: to be more specific: I mean web programming, and indeed maybe a more useful question is:

> What can I do client side that I can't do server side, and vice versa?

> Are there more reasons to use both languages if you keep "server/clientside" out of scope?

> some developers avoid javascript. why?

like image 249
Joris Avatar asked May 27 '10 13:05

Joris


People also ask

Which is better C or JavaScript?

If you want to start a simple web application, then learning Javascript instead of C is a fine approach. If you want to learn to write a desktop app, then Javascript is absolutely the wrong way to go about this.

Is JavaScript easier than C?

In terms of time to learn, C is harder to learn than JavaScript. C is very low level: you have allocate memory, free memory, use pointers and whatnot.

Is JavaScript related to C?

JavaScript is a different language. JavaScript has a syntactic similarity to Java, much as Java has to C. But it is no more a subset of Java than Java is a subset of C.

Is it better to learn C# or JavaScript?

It's also used by 97.6% of all websites, so there is – and always will be – a demand for the skill. In a nutshell, C# is good for beginners because it's easy to learn, but JavaScript holds more opportunities in terms of employment and versatility.


2 Answers

What can I do client side that I can't do server side, and vice versa?

Client-side: Javascript runs in most browsers without a plugin. C# requires a browser plugin like Silverlight. Even though it's running on a client machine, Javascript can't read and write files there. C# in Silverlight may be able to read and write files depending on the Silverlight version and what the client allows. Both Javascript and C#/Silverlight can talk to remote servers.

Server-side: since you control this machine, you can do whatever you want - read files, write files, talk directly to databases, etc. Keep in mind there's nothing stopping you from running Javascript server-side. Check out node.js.

Are there more reasons to use both languages if you keep "server/clientside" out of scope?

I wouldn't leave the execution environment out of your analysis. If you absolutely need client-side interaction and can't guarantee C# will execute on the client, C# isn't practical. Likewise, if your company runs Windows servers and doesn't want to install Javascript runtimes/compilers, you won't be able to use Javascript on the server.

some developers avoid javascript. why?

Problems with Javascript in a browser are absolutely awful to debug. You're running on a machine that's out of your control - the user may be running an obscure or ancient browser, they may be using anti-virus software that mucks with your Javascript, their browser plugins might muck with your Javascript. It's hard.

This is the cost of doing business on someone else's machine, however. If it was easy, a beautiful client-side experience would mean less. Solving hard problems isn't for everyone but it sure is appreciated when it's done well.

like image 76
Corbin March Avatar answered Sep 23 '22 13:09

Corbin March


I take it your real question is, if c# can do everything, why should you use javascript at all? The answer here is performance, both perceived and real. The trick here is that to use c# to do the DOM manipulation normally associated with javascript, a browser has to post back an extra http request to the server and tell the c# code what to do. Lets talk about those extra requests. Spread around a lot of users, they add up very quickly and play havoc on your server infrastructure. The "real" performance issue is that now a lot of work has to happen on your server(s), instead of in your users' browsers. The "perceived" performance issues is that, even if you have the server resources to easily handle all the additional http requests, you user now has to spend extra time waiting for latency incurred by those http round trips.

like image 36
Joel Coehoorn Avatar answered Sep 21 '22 13:09

Joel Coehoorn