3

I'm in the process of creating a grammar for a scripting language but as I'm working on it I started to wonder what makes a language good in the first place. I know the goals for my script but there are always 1000 different ways to go about doing things.

Goals:

  • Easy to use and understand (not my grandma could do it easy, but the secretary at the front desk could do it or the VP of marketing could do it type of easy)
  • No user defined functions or subroutines.
  • Its use would be in events of objects in a system similar to HyperCard.

Conceptually I was thinking of a language like this:

set myVariable to 'Hello World'
set counter to 0
repeat 5 times with x
begin
    set counter to counter add x
end
set myVariable to myVariable plus ' ' plus counter
popup myVariable

set text of label named 'label' to 'new text'
set color of label named 'label' to blue

The end result would popup a dialog with the contents Hello World 15 it would also change the text of a label and make it blue.

But I could do the same thing 1000 different ways. So what makes one language any better than another when both are designed for the same goals?

Steven Jeuris
  • 5,814
  • 1
  • 31
  • 53
Justin808
  • 139
  • 1
    you can do this with C macros if you want... – ratchet freak Dec 02 '11 at 18:28
  • 1
    What are you trying to accomplish here? Is this a "for fun" or "for learning" project? If not, what is the language to be used for, and why don't you want to use an existing one? – David Thornley Dec 02 '11 at 18:41
  • 1
    I do not think it's a good idea to start designing a language from its syntax. Design semantics first, then derive an abstract syntax tree for it, and only then start inventing a syntax front-end. – SK-logic Dec 02 '11 at 19:03
  • 3
    "I started to wonder what makes a language good in the first place." If you don't have an opinion on this already, don't design a language. – Sean McMillan Dec 02 '11 at 19:05
  • @Justin808 Why have you deleted your SO question on that subject? – talnicolas Dec 02 '11 at 19:12
  • 5
    You just basically re-invented AppleScript see HelloWorld in AppleScript. This is universally considered one of the worst language implementations of any languages known! –  Dec 02 '11 at 19:28
  • @talnicolas - it was suggested to move it here and there were no answers on the question. – Justin808 Dec 02 '11 at 19:28
  • 2
    I've gone through this exercise myself a few times, and every time I concluded that what I really needed was a well-designed GUI. Secretaries and VPs aren't going to be able to handle anything more complex than excel. – Karl Bielefeldt Dec 02 '11 at 19:30
  • 1
    @Karl Bielefeldt, Excel is unbearably complex. A simpler language built around simpler visual idiom is better suited - something like wxMaxima, with arbitrarily placed cells and visual links between them. – SK-logic Dec 02 '11 at 19:56
  • I agree, @SK-logic. Excel was meant as an example of the upper bound, and I was only really including the more basic features at that. – Karl Bielefeldt Dec 02 '11 at 20:26

3 Answers3

2

There's no right answer here. Different languages are designed for different things and different styles of programming. This is clear from the design principles of even popular languages. From the Zen of Python:

There should be one-- and preferably only one --obvious way to do it.

Perl was designed using the opposite principle:

There's more than one way to do it

Neither one of these languages did it "right". Some people prefer one style over the other, but it ultimately comes down to stylistic preferences and the goals of the language.

jncraton
  • 121
1

Unless you are an experienced language designer, it might be better to take an existing programming language that has already proven itself useable, useful, and/or perhaps even popular, among some similar target audience, and prune that language's syntax to meet your needs.

hotpaw2
  • 7,978
0

the only thing that matters for a language is that is solves the problem it was designed to solve. what makes a language better than another is that is solves the problem better. In your case it looks like you are stuck on how much like written English should the language be, you could try writing something like in your question several ways you think are pretty good and asking someone which they like the best (preferably someone who is intended to use the language if they exist). if you pick something and stay consistent and try to avoid creating special cases whatever you decide will work quite well.

Ryathal
  • 13,396