locked
When do you use C# and when do you use Javascript? RRS feed

  • Question

  • Seen several examples and sometimes the C# is used and sometimes Javascript is used in the .js file.  When I want to begin a timeline (Timeline1.begin()), for example, I use c# in the code behind.  I've seen other people use javascript when the have a play or pause button.  Both seem to work, so I'm not sure what the difference is.  Different things seem to be exposed in both too.  I'm lost on it.

     

    Thanks.

    Tuesday, August 7, 2007 4:56 PM

Answers

  • It depends what version you're developing.  For 1.0, you have to use javascript.  For 1.1, you can use whatever you want.  I think mostly, you would want to use C# if you can, because that's the whole point of 1.1 (being able to use managed code).  There are a handful of things that you might have to use javascript for, or might be easier with javascript, but they're roughly equivalent.  So there really isn't much difference, it's more a matter of personal preference.

    Tuesday, August 7, 2007 5:30 PM
  • Here are a few reasons I came up with.  Sorry they're all sorta run together.

    I don't think 1.1 is right around the corner.  It's still in Alpha.  There's no official word as far as I know, but I've heard speculation that it will be released around summer of '08.  That's almost a year away!  1.0 is pretty much here now.  I don't think many businesses would want to use an alpha.  Although I would expect the two versions to merge at some point, for now they are separate, and 1.1. requires the 1.1 plugin, whereas 1.0 works with either.  Also, 1.1 doesn't exactly use all of .Net.  There are some pretty big restrictions on what you have access to, due to security considerations, which means some of the things you take for granted in developing a web application (ex. Response.Write) aren't going to be directly available to you.  Developing in 1.0 doesn't require Visual Studio.  Some people also might simply find javascript easier to work with.  Right now, it looks like there's more and better documentation for 1.0.

    But yeah, a lot of people are just kind of ignoring 1.0 and focusing on 1,1.

    Friday, August 10, 2007 2:03 PM

All replies

  • It depends what version you're developing.  For 1.0, you have to use javascript.  For 1.1, you can use whatever you want.  I think mostly, you would want to use C# if you can, because that's the whole point of 1.1 (being able to use managed code).  There are a handful of things that you might have to use javascript for, or might be easier with javascript, but they're roughly equivalent.  So there really isn't much difference, it's more a matter of personal preference.

    Tuesday, August 7, 2007 5:30 PM
  • I agree, in 1.1 it is a matter of preference. Dynamic languages like Ruby and JS has the advantage of simplicity, and ease of development. Static languages like C# has the advantage of strong typing and compiler support.

    Tuesday, August 7, 2007 5:52 PM
  • Then why would I want to do anything in 1.0, if 1.1 uses all of .NET and seems to right around the corner?  It doesn't look like it makes much sense to use 1.0.

    Friday, August 10, 2007 11:55 AM
  • Here are a few reasons I came up with.  Sorry they're all sorta run together.

    I don't think 1.1 is right around the corner.  It's still in Alpha.  There's no official word as far as I know, but I've heard speculation that it will be released around summer of '08.  That's almost a year away!  1.0 is pretty much here now.  I don't think many businesses would want to use an alpha.  Although I would expect the two versions to merge at some point, for now they are separate, and 1.1. requires the 1.1 plugin, whereas 1.0 works with either.  Also, 1.1 doesn't exactly use all of .Net.  There are some pretty big restrictions on what you have access to, due to security considerations, which means some of the things you take for granted in developing a web application (ex. Response.Write) aren't going to be directly available to you.  Developing in 1.0 doesn't require Visual Studio.  Some people also might simply find javascript easier to work with.  Right now, it looks like there's more and better documentation for 1.0.

    But yeah, a lot of people are just kind of ignoring 1.0 and focusing on 1,1.

    Friday, August 10, 2007 2:03 PM