A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Actionscript vs Other coding

  1. #1
    Actionscript Developer KigD's Avatar
    Join Date
    Jan 2003
    Location
    georgia
    Posts
    597

    Actionscript vs Other coding

    Just had a thought about this...

    Why hasn't other programming languages adopted some of actionscript's techniques and coding style? It would be awsome if Java or C++ had an eval command or was able to call functions and methods by using variable names "[varName].sayHello()".
    Also, why don't java and C++ do what actionscript and php do to variables that have not been initialized and make them default, and then convert them to numbers/strings when needed?


    And why hasn't flash adopted some of C++ and Java things? For example, arrays and functions? Like why is creating a function in actionscript different? I'd like to call a function void or tell what type of variable it returns. In a way I like how flash makes it so you can return a variable even if you didn't say that the function does because it auto detects. I want Java and C to do this .

    There are lots of other mini things but I can't remember them right now...


    I'm sure there is an answer to this and I'm just too naive to think about it but I was just speaking my mind.
    K2xL - My games, tutorials, message boards, and experiments.
    Blog

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Having been programming in a lot of different languages for about 20 years, I thought I'd take a crack at this...

    It is probably better that there be differences between programming languages, rather than they all be the same. We need diversity in languages so that each language can find its niche. Some languages, like C are good for writing applications and system software, and other languages, like actionscript are good for making whack-a-mole games.

    > It would be awsome if Java or C++ had an eval command or was able to call functions and methods by using variable names "[varName].sayHello()".

    The Eval() command is something that is unique to interpreted languages, such as Perl, actionscript and Forth. The reason why these languages can do it is because interpreted languages have the 'compiler' (the thing that parses the code and executes it) built right in.

    Compiled languages, like java and C are converted (by the compiler) into something which is intended to be smaller and more efficient (e.g. machine language or java-machine-language), and since the compiler isn't built-in, there is no eval. When a C (or C++) program is compiled, you lose all the symbols - the names of the variables, so any eval which referred to a variable name would be meaningless.

    There *are* a few features in plain-old C that I miss not having in Java and actionscript. I hate the way strings are handled in Java and actionscript. I find the C method more elegant. At the same time, if actionscript did it the C way, most newbie actionscripters would be tearing their hair out.

    I've seen at least two threads today where folks were complaining about not being able to format their dates with leading zeros (09/07). This is something that is quite simple in C using the printf() (print formatted) command. It would be nice if the String object supported something similar.

    > Also, why don't java and C++ do what actionscript and php do to variables that have not been initialized and make them default, and then convert them to numbers/strings when needed?

    This feature is common in "high level" languages. The reason it's not used in Java and C is because it can get you into trouble in very large programs. It becomes very difficult to know where your variables are, and what they were intended to be used for. For the small things that actionscript tends to get used for, it's not a problem. Needless to say, I wouldn't want to use actionscript for a very large (e.g. greater than 10,000 lines of code) project.

    So in short, viva la difference!

    A couple of languages you haven't mentioned are Forth and Lua. They're not very well known outside the insular comunities that use them. They're both pretty interesting in that they're not based on C syntax (as Java, Javascript, actionscript, Perl and C++ are). Believe it or not, not every language uses semicolons and the "==" operator.

    Lua, an interpreted scripting language popular in the game industiry, is probably one of the most elegant languages I've used in the past 10 years - it has a very small number of keywords, yet is robust enough in its syntax to support a wide variety of coding styles.

    Forth, the granddaddy of idiosyncratic languages, is also pretty cool. It uses NO parenthesese (it's the philosophical opposite of Lisp, which uses tons of them).

  3. #3
    Actionscript Developer KigD's Avatar
    Join Date
    Jan 2003
    Location
    georgia
    Posts
    597
    Yeah doesn't VB also have different code? Like
    If (happy)
    Then
    sad = true;


    or something?
    Why don't they make a language that combines all of the others? Then you could like do things from that certain language. Like for example:

    #include <iostream.h>
    import.java.awt;
    void main()
    {
    flash flashAction = new flash();
    java javaAction = new javaAction();

    myInt;

    String myString = "myInt";
    flashAction.eval(myString) = javaAction.length(myString);
    flashAction.trace(myString);
    }


    woudln't that just be so cool?
    K2xL - My games, tutorials, message boards, and experiments.
    Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center