Re: crazy programming language thoughts

Discussion in 'Python' started by Tim Roberts, Aug 26, 2003.

  1. Tim Roberts

    Tim Roberts Guest

    "Ryan Lowe" <> wrote:
    >
    >one of the things i love about python is its use of the actual words
    >or/and/not/is/in, where other languages would use symbols ||/&&/?!@#$%, what
    >have you.


    The "other languages" thing is a little one-sided. C and C++ are really
    the only mainstream languages to use symbols for these constructs. Pascal
    and Algol use the words or/and/not/is/in, as well as begin/end instead of
    {}.

    >the basic concept would be to use identifying words in front of the
    >arguments to determine their identity as well as making the function call
    >read more like an english phrase. for instance, take the simple python
    >statement:
    >
    >>>> vtext.replace('a', 'b')

    >
    >wouldnt it be nicer (more english-like at least) to say:
    >
    >>>> replace 'a' with 'b' in vtext


    You should check out REXX, the primary scripting language for OS/2. That
    line could have been taken from a REXX script practically unmodified.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Aug 26, 2003
    #1
    1. Advertising

  2. Tim Roberts

    Ryan Lowe Guest

    "Christopher Barber" <> wrote in message
    news:p...
    > Tim Roberts <> writes:
    >
    > > "Ryan Lowe" <> wrote:
    > > >
    > > >one of the things i love about python is its use of the actual words
    > > >or/and/not/is/in, where other languages would use symbols ||/&&/?!@#$%,

    what
    > > >have you.

    > >
    > > The "other languages" thing is a little one-sided. C and C++ are really
    > > the only mainstream languages to use symbols for these constructs.

    >
    > and Java and C# and Tcl and Perl and Javascript, all influenced by C of

    course.
    >
    > - C


    ok, but my main point wasnt about disliking symbols, per se, as long as they
    are appropriate. for instance, the $ meaning 'scalar' and the @ meaning
    'array' in front of perl variables are near arbitrary symbols in my mind, as
    are the && and || in c++. what i am attempting to figure out, is if there is
    a way to improve the intuitiveness of the python's syntax, specifically
    concerning functions. the basic idea i started with was:

    > > "Ryan Lowe" <> wrote:

    >the basic concept would be to use identifying words in front of the
    >arguments to determine their identity as well as making the function call
    >read more like an english phrase. for instance, take the simple python
    >statement:
    >
    >>>> vtext.replace('a', 'b')

    >
    >wouldnt it be nicer (more english-like at least) to say:
    >
    >>> replace 'a' with 'b' in vtext


    ive been playing around with the notion of part of speech. ive come up with
    this rule:

    functions are defined starting with a present-tense single-word verb,
    followed by a noun target (not necessarily a variable), followed by any
    other words and/or variables (at least one word must separate each
    variable). this reads well when the function call is a statement like the
    example in the quote.
    however, it reads less well in assignments, conditions, and parameters,
    where its used as an expression. in such cases, the function calls read
    better as noun phrases. i noticed that you can convert a function to the
    noun-form pretty easily, given the function is of the format above, by
    taking the past-tense of the verb and swaping the first two words, like so:

    join listv with '' # verb phrase
    stringv = listv joined with '' # noun phrase
    get fruit from bowlv # verb phrase
    apples, oranges = fruit got from bowlv # noun phrase
    if 'a' replaced with 'b' in textv : # noun phrase
    replace av with bv in listv joined with gluev # combo

    a dictionary of english verb suffixes can be used to automatically define
    the past tense of a verb, even for made-up verbs in many cases, e.g.
    asparagate (turn something into an asparagas), can still be resolvable from
    the suffix ate-> ated.

    so do people think this is an improvement over dot syntax? i think it reads
    better, but then i thought of it ;-)
    do you think it would confuse people in terms of which part is a parameter
    of what when combining 2 functions like the combo example?
    can anyone think of a scenario where it wouldnt work? it only takes care of
    methods, i havent figured out how to de-dottify class functions and class
    attributes. others pointed out that other languages use labels for
    arguments, but i dont know any that use this rule system.
     
    Ryan Lowe, Aug 28, 2003
    #2
    1. Advertising

  3. Tim Roberts

    Sean Ross Guest

    "Ryan Lowe" <> wrote in message
    news:3rv3b.6241$...
    > what i am attempting to figure out, is if there is
    > a way to improve the intuitiveness of the python's syntax, specifically
    > concerning functions.


    Hi. I'm pretty sure you will not find a lot of support in this forum for
    changing
    Python in the way that your hoping. You're pretty much proposing a new
    language, not just enhancements for an existing one. But, whatever ...

    Personally, I really like the *idea* of an english-like programming
    language -
    I'd like to make one myself, and I think it'd be a fine toy for simple
    scripting.
    However, I also think it would become cumbersome as the scale of your
    projects grew. Heck, it's cumbersome even when your projects are small.
    English is not always the most concise way to say something, nor is it
    always the most clear. Take the following Applescript code for example:

    What is the result of each of these statements:

    words from paragraph 2 to paragraph 4
    words of paragraphs 2 thru 4
    text from paragraph 2 to paragraph 4
    text of paragraphs from 2 to 4

    They're all different.

    The answers can be found here:
    http://www.applescriptsourcebook.com/tips/gotchas/ranges.html


    > do you think it would confuse people in terms of which part is a parameter
    > of what when combining 2 functions like the combo example?



    In Applescript, you can (optionally) use parenthesis to (attempt to)
    disambiguate. So, for example, in your case, doing something like

    replace av with bv in (listv joined with gluev)

    might make things a bit clearer.

    > i havent figured out how to de-dottify class functions and class
    > attributes.


    Well, you could do something like this (applescript-like, again):

    -- If you have an instance of the class
    set the attribute of instance's class to value

    -- or
    set the attribute of the class of instance to value

    -- or, maybe even,
    get the attribute of instance's class
    set it to value


    -- And, if you don't have an instance, or you just want to get there
    directly
    set className's attribute to value



    Anyway. It's an interesting idea (your language) - not a new idea, but an
    interesting one. If you want to play around with something very much like
    Applescript, but you don't have a Mac, you can get a trial version of
    MetaCard (www.metacard.com). And, if you really want to make your own
    language, you could use SPARK, as a start, to whip up a (slow) prototype
    to mess around with and see how things should go together. As for getting
    Python to _become_ your language ... well, good luck with that.

    Sean
     
    Sean Ross, Aug 29, 2003
    #3
  4. Tim Roberts

    Ryan Lowe Guest

    "Sean Ross" <> wrote in message
    news:35y3b.3262$...
    > "Ryan Lowe" <> wrote in message
    > news:3rv3b.6241$...
    > > what i am attempting to figure out, is if there is
    > > a way to improve the intuitiveness of the python's syntax, specifically
    > > concerning functions.

    >
    > Hi. I'm pretty sure you will not find a lot of support in this forum for
    > changing
    > Python in the way that your hoping. You're pretty much proposing a new
    > language, not just enhancements for an existing one. But, whatever ...


    im not trying to change python. even a small change is a tough sell with
    this crowd ;-) i guess i should have labeled this off-topic. is there a
    forum that might be more appropriate?

    actually, i would like to make my own language, sort of. what id like to do
    is compile to regular old python code, instead of directly to executable.
    that way i wont have to reinvent the wheel for the parts of python i would
    keep in my new language (which is a lot), as well as all the libraries and
    such. maybe ill find this will become too difficult, but what the hell, i
    ought to learn a thing or two in the process.

    > Personally, I really like the *idea* of an english-like programming
    > language -
    > I'd like to make one myself, and I think it'd be a fine toy for simple
    > scripting.
    > However, I also think it would become cumbersome as the scale of your
    > projects grew. Heck, it's cumbersome even when your projects are small.
    > English is not always the most concise way to say something, nor is it
    > always the most clear. Take the following Applescript code for example:
    >
    > What is the result of each of these statements:
    >
    > words from paragraph 2 to paragraph 4
    > words of paragraphs 2 thru 4
    > text from paragraph 2 to paragraph 4
    > text of paragraphs from 2 to 4
    >
    > They're all different.


    thats interesting. thats pretty much the impression i got from applescript.
    i think it goes too far trying to be english-like to the point of
    obfuscation. i see no need to english-ify selecting a range of things from a
    list.
    id do something like:

    get words in paragraphs[2 : 4]

    where paragraphs is a list of strings each containing a paragraph of text
    and "get words in _" is a function call and the *only* form it can be
    written (in verb form, that is; in noun form the only way would be "words
    got in _").

    so i can dodge this bullet, but running into the type of problem in this
    example is exactly what im concerned with. as it stands, i dont think the
    difference between my way and python's way is as different as between my way
    and applescripts.' i use function calls just like python, only they span
    multiple words with the args interspersed instead of bunched up at the end.

    part of my motivation for attempting this comes from my ongoing struggle to
    understand functional programming, which goes to the extreme of putting
    functions/operators in the wrong place vis a vis the arguments. so i guess
    my main point in asking here was to see if people with more oo and/or
    functional lang knowledge can find where/if my model breaks down. because,
    id like to build much more than a "toy" language.

    > The answers can be found here:
    > http://www.applescriptsourcebook.com/tips/gotchas/ranges.html
    >
    >
    > > do you think it would confuse people in terms of which part is a

    parameter
    > > of what when combining 2 functions like the combo example?

    >
    >
    > In Applescript, you can (optionally) use parenthesis to (attempt to)
    > disambiguate. So, for example, in your case, doing something like
    >
    > replace av with bv in (listv joined with gluev)
    >
    > might make things a bit clearer.


    sure thats the obvious solution. it would suck (just a little) if every
    expression-argument needed parens, while the comma and single outer parens
    work in traditional functions, but thats minor.

    > > i havent figured out how to de-dottify class functions and class
    > > attributes.

    >
    > Well, you could do something like this (applescript-like, again):
    >
    > -- If you have an instance of the class
    > set the attribute of instance's class to value
    >
    > -- or
    > set the attribute of the class of instance to value
    >
    > -- or, maybe even,
    > get the attribute of instance's class
    > set it to value
    >
    >
    > -- And, if you don't have an instance, or you just want to get there
    > directly
    > set className's attribute to value


    or just
    attribute of classInstanceVar = value

    the 'of' works like the dot only in front. may conceivably cause problems if
    functions have ofs in them, but since it works on the front while other
    function words go behind, i think its resolvable.

    can anyone think of something you couldnt do with this, that you can in
    python? i know applescript is limited, but does my language suffer from
    similar challenges? any functions that would translate to a simple
    verb-noun-args and other words setup?

    >
    > Anyway. It's an interesting idea (your language) - not a new idea, but an
    > interesting one. If you want to play around with something very much like
    > Applescript, but you don't have a Mac, you can get a trial version of
    > MetaCard (www.metacard.com). And, if you really want to make your own
    > language, you could use SPARK, as a start, to whip up a (slow) prototype
    > to mess around with and see how things should go together. As for getting
    > Python to _become_ your language ... well, good luck with that.
    >
    > Sean


    SPARK, huh. never heard of it, ill check it out. thanks
     
    Ryan Lowe, Aug 30, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Istvan Albert

    Re: crazy programming language thoughts

    Istvan Albert, Aug 22, 2003, in forum: Python
    Replies:
    1
    Views:
    338
    Ryan Lowe
    Aug 23, 2003
  2. Sean Ross
    Replies:
    0
    Views:
    377
    Sean Ross
    Aug 22, 2003
  3. Ryan Lowe
    Replies:
    1
    Views:
    343
    Sean 'Shaleh' Perry
    Aug 23, 2003
  4. spiffo
    Replies:
    18
    Views:
    494
  5. Replies:
    28
    Views:
    1,174
Loading...

Share This Page