Understanding/Learning scripting language(s) from a compiled language developer perspective [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have been a C-derived language (c, c++, c#, etc..) developer for about 7 years. I have managed to avoid doing scripting language programming so far. But trying to avoid the unavoidable is doomed to be a failing course.
Now I have to teach myself a scripting language or two for work. Before I start this "pleasant" journey of learning a new programming language again, I would like to have a high-level guidance about scripting languages.
Q1, Why did we invent scripting languages? What is so great about scripting languages (python, javascript, etc.) that other compiled languages cannot do?
Q2, I need to learn both Python and JavaScript. Is there any advantages to learn them together? Will I save time by doing so? Or it does not make sense to learn two different languages at the same time.
Q3, As we all know, learning the syntax of a language is just the beginning. What are the pitfalls we need to watch out for when learning scripting languages with a compiled language background?
For example, c++ syntax does not tell you that if you dont pair new with a delete, you leak memory.
void leaking_function()
{
//correct syntax in c++, but leaking memory every time it is called.
void* leak = new int[10];
}

Q1: why need scripting languages :
Answer :
Scripting languages are quick and easy .Compiled languages are much
more efficient - for which you pay an up front price in complexity.
you want to write something quickly and then never use it again, 'scripting' languages are what you want.
Features of scripting language:
easy to learn and use
minimum programming knowledge or experience required
allow complex tasks to be performed in relatively few steps
allow simple creation and editing in a variety of text editors
allow the addition of dynamic and interactive activities to web pages
editing and running code is fast.
Q2: I need to learn both Python and JavaScript. Is there any advantages to learn them together?
Answer :
comparison to JavaScript, Python is much well designed, stable and
robust. It has better, cleaner syntax and common-sense patterns.
Python is the predominant language in the world of scientific
simulations and data analysis.
JavaScript, on the other hand, is the language of the web. It's not the prettiest language out there, but you can use it to build rich applications that anyone in the world can run just by typing an address in their browser
Node.js has proven that it can more than hold its own outside of the
browser as well
Anyway learn both languages is a good deal. But in my openion take one from the above it will be upto your choice, its complitly depends on your working area and interest.Then learn that one in depth and work on it.
Q3: What are the pitfalls we need to watch out for when learning scripting languages with a compiled language background?
Answer:
If you know the basics of any programmig language then it is easy to learn scripting languages too.Most of the compiled language features are also included in scripting language too.
Note: you have to compile a C program before you can run it. But you don't have to compile a JavaScript program before you run it.keep this in your mind before you learn scripting language.
When you write scripting language always think about security hackers can easily hack our site if we did not provide a high security.

Related

What's the point of using Opal? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Opal looks like nice library, but I'm not sure if there is real use for it. How do you use it? Or is it just a curiosity?
Ruby is a programming language. A programming language is a set of abstract mathematical rules and restrictions. It is an idea, a specification, a piece of paper.
You can write programs in a programming language, but if all you have is the programming language itself, then all you can do with those programs is read them, study them, prove properties about them, etc. But you cannot run them (other than in your head or using pen and paper).
That does not make the programming language useless, however. There are plenty of programming languages that were never implemented, they were only created in order to write programs and prove properties about those programs, or study properties of the programming language itself.
Ruby, however, is intended as a practical programming language. Programs written in Ruby are meant to be executed, and not with pen and paper.
Which means we need another piece of the puzzle, we need what is called a programming language implementation.
A programming language implementation is itself a program written in some programming language (it could be the same one or a different one) that "understands" programs written in the programming language and does one of two things with them:
It "runs" them, meaning it performs the side-effects and operations of the program according to the specification of the programming language. This kind of implementation is called an interpreter.
It "translates" them into a different programming language, i.e. it translates a program written in the source programming language into a semantically equivalent program in the target programming language such that interpreting the resulting output program with an interpreter for the output programming language yields the same results and performs the same side-effects as interpreting the source input program with an interpreter for the input programming language.
Ruby actually has quite a number of programming language implementations:
YARV
MRuby
TruffleRuby
JRuby
Rubinius
Artichoke (still in development)
Ruby+OMR (not sure whether this is still developed)
IronRuby (no longer actively developed)
Opal is simply yet another programming language implementation of Ruby. In that regard, it is no different from any of the others. All of them have their strengths, their weaknesses, their use cases, their niches.
Opal is somewhat unique compared to the other ones in the list, in that it is a pure compiler. XRuby and Ruby.NET work the same way, but those are no longer being developed. All of the other ones in the above list use an interpreter for at least some code some of the time in some form. For example, while YARV never interprets Ruby, it always compiles Ruby to YARV byte code, it typically interprets that YARV byte code at least a couple of times before handing it off to the JIT compiler.
So, the reason to use Opal is the same reason to use any of the other Ruby implementations: you have a Ruby program and you want to run it. And in order to run it, you need a Ruby implementation.

Opa vs Dart vs Haxe vs CoffeeScript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been googling for latest web apps, and found the following languages:
- Opa
- Dart
- Haxe
- CoffeeScript
Since these languages are new, there are not many information available.
Can anyone explain the advantages and disadvantages of these languages.
EDIT:
Which language is efficient?
What new features are available in each languages?
How can it improve existing languages like JavaScript?
Which will be easy to learn?
Opa
Functional programming
Pro: Run client, server, and database code in the same language
Con: Currently the least popular of these languages
Dart
Similar to Java/JavaScript
Pro: Can run client and server code in the same language (though in practice, this is not yet the best option)
Pro: In the future you will be able to run client code in the Dart VM in some browsers
Pro: Polymer MDV provides easy approach to encapsulation and re-use of components
Haxe
Similar to ActionScript
Pro: Mult-platform language: compile to other language/platforms besides for JavaScript (for instance, creating high-performance mobile games)
CoffeeScript
Similar to Ruby
Pro: Currently the most popular of these languages
Some features common to all the languages:
Compile to JavaScript
Interact with JavaScript code
I researched all of these for a project that never ended up happening. I never really got into CoffeeScript since it was less familiar to me given its Ruby flavor. Opa was very intriguing but I ultimately decided against it since it seemed to have a very small community, and I preferred something more class-based and object-oriented. I was familiar with Haxe already, having played around with it for a mobile game, but JavaScript didn't seem like a huge focus here: tutorials and samples were hard to come by.
With Dart, everything suddenly seemed to come together:
Given my Java/ActionScript/JavaScript background I knew the language before even writing a line of code
The WebUI (now Polymer) Model-Driven-View approach, provided a sane way to encapsulate and re-use components
A dedicated IDE (Dart Editor) that made debugging quick and easy
Pub package manager made it easy to quickly add 3rd-part libraries
Plenty of tutorials, articles, and documentation to help get me up to speed
Ultimately, you can build great web apps in any of these languages, but the one you choose will be influenced by your past experience. In my case, I was looking for a class-based, object-oriented solution, which made it between Haxe and Dart, and Dart was clearly the victor in terms of features, tooling, and support.

Why is javascript the only client side scripting language implemented in browsers? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Why don't browsers add support for, say, Python scripting as an alternative to Javascript? Or more general purpose scripting languages? Is there a reason that Javascript is the only one implemented across browsers? After all, the script tag does have support to specify the scripting language used.
(I know there is VBScript support in IE, but it seems obsolete for all intents and purposes.)
Well, Google is trying to buck that trend with Dart. The community hasn't been entirely receptive to the idea; either.
Google proposed adding multiple VM support for Webkit which didn't go down very well.
One particular comment summed it up nicely as to why there has been some resistance to that:
In this case the feature is exposing additional programming languages to the web, something without any real benefit to anyone other than fans of the current "most awesome" language (not too long ago that might have been Go, a year or so ago this would have been ruby, before than python, i recall i brief surge in haskell popularity not that long ago as well, Lua has been on the verges for a long time, in this case it's Dart -- who's to say there won't be a completely different language in vogue in 6 months?), but as a cost it fragments the web and adds a substantial additional maintenance burden -- just maintaining the v8 and jsc bindings isn't trivial and they're for the same language.
The issue here isn't "can we make multiple vms live in webkit" it's "can we expose multiple languages to the web", to the former i say obviously as we already do, to the latter I say that we don't want to.
Unless we want to turn webkit into the engine that everyone hates because of all its unique "features" that break the open web, a la certain browsers in the late 90s.
CoffeeScript is another example of an emerging client-side scripting language. However, rather than support another virtual machine in a browser (as Google is trying to do with Dart), it compiles to JavaScript. There are several other "compile X to JavaScript" that do that as well. emscripten is a good example of compiling LLVM to JavaScript.
So there are plenty of other client languages; they just all use JavaScript as an intermediate. I'd argue that should be what Dart does as well, though they have some room to improve.
Internet Explorer supports any Windows Script Engine, so you can make it support any language that has been implemented as one, or write your own.
Because JavaScript is what every other browser supported, and browser vendors had two main priorities:
Making sure existing webpages worked (which requires JavaScript)
Letting authors do user visible things in their browser that they couldn't do in other browsers (changing programming language would be entirely hidden from users, except when it broke).

Javascript or Python? beginner getting up to speed [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Which language will allow a beginner to get up to speed quicker?
Basically which language of the two is easier to learn
Python is more regular, and has not needed to keep supporting every old, redundant feature forever, as Javascript has been forced to do (in order to keep supporting existing sites): these are issues that can make Python easier to learn.
However, Javascript's not too bad, especially if you can choose a reasonably rigid, modular, clean framework such as dojo (if you have to learn about every popular JS framework, or even most of them, it will, however, be a nightmare -- as it will if you have to learn the subtle bugs and incompatibilities of various browsers' implementations of JS and the DOM, rather than getting them covered up by such frameworks as dojo, jquery, or closure).
For learning Javascript, I recommend supplementing whatever tutorial you choose with Crockford's Javascript: the good parts -- it's a very thin book (which sounds like a joke, but it's true!-), fast and easy to read, and stops you from wasting your time on language features that are misconceived, too badly designed to use, or counterproductive. Crockford is a real JS guru and is well worth reading and paying attention to.
Depends what you want to do. If you're just interested in learning a programming language, I would recommend Python because:
The interactive prompt is great for learning a language
It's simple and well-designed, whereas JavaScript has a number of design flaws that can be confusing to newbies
There is a particularly high amount of introductory materials for Python.
It allows you to do all kinds of programming (server, client, games, etc.), whereas JS will limit you a bit more.
They're both pretty straightforward to learn. They more differ in terms of their typical project space - Javascript is usually utilized more for the client-side portion of web applications, while Python is often utilized for the server side of web applications and also standalone non-web apps.
What do you want to make?
The two languages are used for two completely different purposes. JavaScript does work in the browser,1 Python does work everywhere else. Pick the language based on which you want; it's useless to learn a language if you can't even use it for your project. If you want to make a website, for example, you'll have to learn both--JavaScript for the client and Python for the server.
Regardless, to answer your question, both languages are great but I'd say Python is easier to start with. JavaScript's basics are fine, but it features a lot of advanced concepts that you shouldn't have to deal with when learning your first language, IMO.
1. Yes, I'm aware that you can use JavaScript on the server-side, but those implementations are not mature and certainly not for a beginner. Python is much more suited for that kind of thing.
PHP is my thing, but I've played with Python and worked with JS. Being only somewhat skilled in both languages, Python feels nice and clean (although a little wierd) with the forced tabbing conventions and lack of semicolons. JS, on the other hand makes me feel like I need a shower. Especially after debugging in IE.
But the only real answer is the question - What do you want to do with it? Want to make websites do cool things in the browser? Go with JS. Something else? Maybe Python is better suited, as #Amber said.
Edit: As for getting up to speed, here's how it works. Your first language takes you a longer time to learn. Your second takes much less time, and after that it's not long at all since you're mostly just learning new syntax for similar things. So the solution for getting up to speed faster is to jump in right now.
I would say JavaScript is easy to learn. I had to learn it to program the Karotz. It only took about 2 months of Youtube tutorials to learn most of it.

Would javascript and similar scripting languages benefit from being strongly typed? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Just had my mind going today. I spent some time in IE debug mode, browsing the web as usual, and oh boy do I see many errors :) Most of these errors are because some value are of a different type than expected (at least as far as I interpret the error messages).
What are the reasons JavaScript and similar scripting languages aren't strongly typed? Is it just to make the languages "easier" to understand and more accessable, or is the lack of a "compile-time" the real problem?
It should definitely have strong typing available. Actionscript 3 is strongly typed, but still has prototype inheritance and a wildcard type if you need dynamic objects.
There are no downsides to having that feature available, and I have to say, for a project of moderate to large size, strong typing prevents A TON of problems. To get the most out of it you need IDE support so it can report errors and provide autocomplete options, but Javascript would be in a whole new world if it had real classes and strong typing.
It gains flexibility from not being typed. I personally enjoy the weakly typed languages.
So the answer is there'd be benefits and drawbacks.
For people who want a strongly-typed language in the browser, GWT and Script# are available.
Would javascript and similar scripting languages benefit from being strongly typed?
Yes, they would, JavaScript 2.0 introduces a type system:
Type System
JavaScript 2.0 supports the notion of a type,
which can be thought of as a subset of all
possible values. There are some built-in
types such as Object, Number, and
String; each user-defined class (section 6)
is also a type.
Also see: http://timkadlec.com/2008/04/an-objective-look-at-javascript-2-0-strong-typing/
In general, support for strong typing provides many interesting opportunities for the compilation and optimization passes.
My own oppinion: You could parse scripts before executing them. This would catch most type-errors, and mean that the user doesn't have to see a partly-executed-then-terminated scriptresult. Even better, it would be a lot easier to debug the thing, if it had a parser :)
I like the weak typed aspects of most scripting languages for the most part. The only reason that I would want strongly typed, besides for performance, is that it is easier for tools to refactor strongly typed languages than weak.
I build a rapid prototype framework for eLearning in ActionScript 2 way back when. My biggest gripe was AS2 was not strongly typed and it causes me many a headache when debugging. I think that strongly typing things makes code easier to read. I think a weakly typed language offers more flexibility.
I lean more towards readability when i have to go back and figure out what the heck is going on in code i wrote 6 months ago.
Microsoft has gone a long way to solving strong typing the problem in the interim with typescript. Have a look:
http://www.typescriptlang.org/

Categories