Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As a developer who spends most of my time in either Java or Javascript these days, I have this fantasy about a language that blends the two of them together. I'm always missing something from one or the other. I know neither is perfect, but to me, they both can be considered the mainstream, modern decendants of C.

I know the popular opinion is that they are completely different languages with only superficial similarities (obviously the name, but also lots of syntactical similarities, especially at the statement and expression level). However, I think that in theory anyway, it should be possible to create a new language, which is essentially a superset of both Java and Javascript (non-strict, of course). Sure there would be challenges in making a language that is loosely typed in some places and strongly typed in others, compiled in some places and interpreted in others, etc.... but my gut feeling is that none of these would be show stoppers (except for those with open minds and good imaginations).

Aside from issues of "where they run" (browser vs. server side, etc)....what are the issues that would come up, especially on the syntax side? How could you handle the situations where the two languages would otherwise conflict? What would it look like?

I can appreciate it if you just think "it shouldn't be done" or "what a nightmare working in that language", but I'm hoping for responses from people with open minds and that have more to say than that...

share|improve this question

closed as too broad by gnat, MichaelT, Dan Pichelman, Kilian Foth, Robert Harvey Aug 8 '13 at 18:01

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Take a look at ActionScript 3. It's an ECMAScript descendant with strict typing and traditional class syntax. –  Joeri Sebrechts Nov 20 '10 at 5:36
    
@Joeri Sebrecht, Thanks, that is interesting, I didn't realize how similar Actionscript is getting to Java. –  rob Nov 20 '10 at 5:49
    
This is like asking if you can combine cars and carpets, sure you can do it... –  TruthOf42 Feb 24 at 13:38

1 Answer 1

up vote 2 down vote accepted

This is exactly how most programming languages come about. Few, if any these days, are created in a vacuum. They are some hybrid of existing languages, taking a feature from language X, another feature from Y, and so forth. Languages scratch an itch. A programmer thinks "Language L is great, but it would be really great if it also did [insert feature here]."

So to start, you need to be more specific about what you like and dislike about Java and what you like and dislike about JavaScript. Then you can talk about creating something new -- something that's a blend of the features from both languages.

Dismissing the question by saying that both languages have different lineages and are therefore unmixable is not giving credit for what any language is: a set of syntactic and semantic features. JavaScript has one set, Java has another set, and both sets overlap in certain places.

So rather than saying you want to blend Java and JavaScript, it's better to talk about creating a language with the set of features you want, some of which happen to come from Java, JavaScript, and perhaps others.

share|improve this answer
    
Well, part of what I want, from a practical point of view, is to be able to build libraries that can be used in either. I like the structure and compile-time type checking of java, but don't want to be forced to use it always. And I love the expressive object-literal format of javascript that is the basis of JSON. –  rob Nov 20 '10 at 5:37
    
How about Rhino, a JavaScript written in Java? –  Barry Brown Nov 20 '10 at 6:12
    
Yeah, that's not what I mean. I mean a new language which is a mix of the two, not a language where its compiler or runtime is implemented in another language. –  rob Nov 20 '10 at 6:36
    
The trouble is when the thing you like in one language is the thing you don't like in another yet in a different context is something you really like. Confused? For example, I like static typing because it makes me much more productive in IDE's but I like dynamic typing because it makes me more productive outside of IDE's and gives me more flexibility. You see, I like both approaches depending on the context. Some languages try to give you the best of both, like Objective-C, although really Objective-C is a statically typed language. –  toc777 Mar 31 '11 at 17:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.