views:

316

answers:

12

Hi!

I recently learned JavaScript an all of the sudden I hear about Python...

Should I go learn Python or just stick with my basic JavaScript knowledge?

If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...

Thanks :)

+5  A: 

Javascript is primarily for client-side ( browser ), Python is primarily used for server-side - so they serve different needs ( disregarding the Python to JS converters and all ).

I would recommend learning Python though, as it influenced ECMAScript and the syntax is very similar, both are object oriented, both are great languages.

http://hg.toolness.com/python-for-js-programmers/raw-file/tip/PythonForJsProgrammers.html

meder
although I wish it was
John Berryman
You mean like Python on DLR? http://msdn.microsoft.com/en-us/magazine/cc163344.aspx
Tetsujin no Oni
JavaScript can be client side. It isn't inherently client side. http://en.wikipedia.org/wiki/Server-side_JavaScript
David Dorward
JavaScript isn’t just browser-based — [node.js](http://nodejs.org/), for example, uses JavaScript outside of the browser.
Paul D. Waite
@David, @Paul - in most cases it's used as client-side.
meder
@meder: very true, although the server-side JavaScript trend seems to be upward, not downward, so it’s worth mentioning.
Paul D. Waite
Yes, Python can actually be used on the client side with gestalt and the dlr like `<script type="text/python">window.Alert('Hello World')</script>` http://ironpython.net/browser/
jcao219
+11  A: 

The two are generally used quite differently. Javascript is primarily used as a client side scripting language vs python which is a server based language. So in a website you could use both. But not sure if this is what you were wondering.

spinon
A: 

JavaScript and Python are both great languages that are geared toward different problems.

JavaScript knowledge is invaluable when dealing with the web, writing web pages, and poking around in html DOM.

Python is a scripting language that is great for a host of things on any machine.

John Weldon
+1  A: 

IMO Python may be easier to learn (having taught both to intro classes).

Also, one major annoyance of JavaScript is that in runs in your browser. This inherently makes it much harder to debug problems.

In terms of a production-level language, Python is more of a general purpose programming language, while JavaScript is targeted at building dynamic web applications.

If you want to get into programming, you should definitely learn a more general purpose language such as Java or Python.

orangeoctopus
There is growing use of JavaScript as a non-browser, server-side language - see node.js for starters. Not sure why, but there is . . .
JulesLt
Interesting- i find in-browser javascript much MUCH easier to debug than almost any server-side logic.
Scott Evernden
+1  A: 

For what purpose? Javascript is king in some circles (web development, for instance).

Javascript and Python are not mutually exclusive. Why not learn both?

Humberto
+1  A: 

JavaScript is usually used as a client-side scripting language - that is, it gets downloaded and executed by your browser. Python, however, is usually not coupled to the web. it can be used as a server-side scripting language, and for scripts and applications of any kind. But it is not a client-side language, and is therefore not directly comparable to Javascript, which has an entirely different audience.

Looking at the language level, Javascript is terrible and dysfunctional (hard to debug, clumsy object-orientation) while Python is beautiful and expressive. This is, of course, subjective :-)

Alexander Gessler
I'm not sure why everyone is saying Python isn't a client-side language. It's a general purpose language and can be adapted to any need - with stuff like wxPython, Python can really do wonders on the client. There's a difference between "is not" and "isn't best at".
Jed Smith
“I'm not sure why everyone is saying Python isn't a client-side language.” — I think they mean “client-side” in the sense of “runs in a web browser”. I don’t know of any browser than runs Python like it runs JavaScript.
Paul D. Waite
A: 

It depends.

Do you want to program in a language that specifically targets web browsers? Stick with Javascript

Do you want to write... well anything besides for web browsers? Learn Python.

Python is an excellent beginner language that's not just a beginner language. Google uses it, NASA uses it, and many, many other organizations use Python.

Wayne Werner
+4  A: 

If you're just learning a language, then there is none better than Python. It's an easy language to pick up. It's well documented. It's associated with a large, active, and friendly community. Since it's a scripting language, you can easily try stuff out and immediately see the results. You can also build up from programming basics, starting by learning functions and then moving into classes.

Javascript is the bane of many a programmer's existences. It's easy enough to learn, but once you start making anything big, it because impossible to keep track of. I'm sad that we haven't moved on to something more advanced.

As noted by spinon, these programming languages are used in very different ways. Python is a general scripting language, which can sometimes be used to do server-side work. Javascript is solely used for building interactivity on web pages.

John Berryman
I would say JavaScript is very advanced, if you find a large project difficult to keep track of then you are not maintaining your resources properly. A framework can help there, see http://www.sproutcore.com as a great example of how easy a large project can be. Even if you are not using an advanced library a copy of JavaScript the Good Parts http://www.amazon.com/exec/obidos/ASIN/0596517742/wrrrldwideweb will keep you on track.
Pullets Forever
Holy sh**, @Pullets Forever! Have you seen one of sproutcores external javascript files? I wouldn't excactly call that easy ;) It took me about 5 minutes scrolling down while I was not reading, just holding down the little scroll-arrow (button-right corner) :D
Latze
Are you talking about a built SproutCore project or the source code? The files I use every day are very easy to modify since they are divided into many smaller files by MVC, logical function, and finally object.
Pullets Forever
A: 

Along with Python generally being server-side and JavaScript client-side, Python was designed to not only be easy to learn, but also easy to read, and to encourage a more productive environment.

Zonda333
+1  A: 

The key fact is that Javascript is very hard to ever change (because of billions of old implementations existing in browsers), so design errors made in early (and frantically hurried;-) stages are still with the language today. (See Crockford's Javascript: the good parts for a reasonable discussion by a JS expert and enthusiast about the good and bad parts thereof). This might change if something like a use strict; directive ever makes its way into ECMAscript (though programming in ways that support old, and often buggy, browsers, will still be like pulling teeth -- like writing Python code that runs unchanged all the way from Python 1.0 to 3.1 would be!-).

Python is deployed in more traditional ways, so gradual language changes have enhanced it over the years (it was also designed with less hurry, and [[arguably, not "a fact";-)]] ended up with a better design from the start, in many respects).

As a result, Javascript (so far) has not enjoyed much success "server side", where programmers get a choice (even though they still have to use JS for "browser side" code). But there's nothing intrinsic to that. JS is by far the most widely deployed language in the world (those billions of browsers...), huge investments are made in it by many companies and open source groups in competing implementations and supporting frameworks (Python's no slouch at that either, but the difference is still there), practical improvements (speed, warnings) keep piling up on JS's side as a consequence (even though the language proper can't improve).

With strict self-imposed programming discipline (enforced e.g. by Crockfor's "lint" program for JS) and a good supporting framework (jQuery, Dojo, Closure, ...) and tools (Firefox has maybe the best add-ons for JS tracing and debugging, but other browsers are rushing in that direction too), JS has become usable in recent years. Probably one of these days a fast server-side implementation (probably with "use strict;" or the like enforced, once that's officially blessed;-) will start gaining a substantial foothold, just because so many web programmers already have some JS knowledge (they have to, to make good web apps).

Note that much of JS's bad rep (beyond the acknowledge "bad parts that can't be removed";-) comes from stuff that doesn't really "belong" to JS as a language: buggy implementations, the mess that the HTML DOM can often be (esp. with buggy browser impementations), etc. There is no reason a future server-side deployment should reproduce these maddening defects!-)

Alex Martelli
+1  A: 

Python’s a good second language to learn after JavaScript, as they have a reasonable number of similarities, e.g.

  • they’re both memory-managed
  • they have similar data structures — JavaScript’s objects and arrays are much like Python’s dictionaries and arrays
  • they’re both used quite a lot for web-related work — JavaScript in the browser and in server-side contexts like node.js, Python in web frameworks like Django.

However, Python’s object-oriented... stuff is quite different to JavaScript’s protoype-based object-oriented stuff.

If the only programming you do is manipulating web pages within the web browser, then Python won’t be of any direct use to you (only JavaScript runs in browsers at the moment). But learning another programming language generally gives you new ways to think about the languages you already know. Learning Python could help you write better JavaScript.

Paul D. Waite
A: 

If you need to ask, then I would say no since you don't have a need in mind for its usage.

Don