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.
Related
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
I know there's a difference between the languages, such as classes etc.
What I wonder is this: If UnityScript is different from Javascript, why does the Unity3D documentation give you the options to pick between C# and JS when you look through it? Shouldn't it be a choice between C# and US?
Meanwhile, here on Stack Overflow, people generally make the effort to correct people who call it Javascript. Why is that?
Unity uses a custom JavaScript variant also known as UnityScript which it historically and still today commonly (but inconsistently) refers to as "JavaScript," including as you note in its own script documentation.
This is incorrect in terms of the meaning of the term "JavaScript" in the programming world at large (i.e. beyond the Unity community). UnityScript is definitely not JavaScript. They are incompatible languages with fundamental differences. From a strict correctness point of view, yes, Unity should use "UnityScript" in its documentation.
The incorrect usage doesn't tend to be problem within the Unity community, within which it is assumed that "JavaScript" means the JavaScript used by Unity. In fact, it's possible that using the term "UnityScript" could cause confusion within the Unity community, because the term "JavaScript" has historically been and continues to be more commonly used, and it's possible many non-programmers within the Unity community don't even realize Unity is actually using a variant JavaScript, as opposed to actual JavaScript.
However, outside of the Unity community, including here on Stack Overflow, using the term "JavaScript" to mean anything other than the actual JavaScript will cause confusion, which is why it's important to say "UnityScript" here.
Incidentally, Unity adds to the potential confusion, both within and without the Unity community, by not being consistent. In its release notes for version 5, it used both "JavaScript" and "UnityScript" interchangeably. In a blog entry about an important scripting change, it used the term "UnityScript-aka-Javascript."
Quote from Juhana, thank you for the answer.
JS and US have enough differences that it's important to distinguish
between them when you ask a question. Otherwise you might just waste
people's time when their answer is incompatible with what you're
actually using. On Unity's site on the other hand there's no danger of
confusion because it's obvious from the context that they're always
talking about Unity and never about non-Unity 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.
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.
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).
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/