Frage

I'm developing my own programming language in my spare time as a hobby. It's an interpreted language. Currently the syntax for variables is this:

%<variable> = <value>

Here are some examples:

%test = 10
%somevar = "Hello World"

At the moment you can just declare as variable as shown above, regardless of the type. You can even change the type through the program if you want.

I've never studied Computer Science, so I'm not really aware of the Pros and Cons of static vs dynamic typing. Here are my questions:

  1. Is it faster to program using dynamic types?
  2. Is there any major advantage to going with static typing?
  3. Is this syntax good for a static language?
  4. Should a language that makes you write the type of the variable beside it when you create it allow you to change the type of a variable at run time?
  5. Should I allow both static and dynamic typing?

Example Syntax:

%somevar int = 10
%another str = "Hello World"

Here's a link to my GitHub, if your interested: https://github.com/reedoolang/reedoo

War es hilfreich?

Lösung

I'm not sure there's good, clear, definitive answers for your questions, I would like to try and help.

  1. There is no definitive proof one way or another. This is one of the great debates amongst programmers. Many argue it is faster to make the program due to lack of type annotations, while many others counter "but it doesn't work! Now you need to write all of the tests that static typing would do for you!". There's also disputes that arise because different solutions better fit different problems, different programmers work differently, etc.
  2. Yes, this is well covered elsewhere.
  3. Sure? You haven't included much, but it seems unambiguous which is the primary concern. Though it should be noted that beginners commonly overvalue syntax over semantics.
  4. No. The type annotation is providing a contract or guarantee about that variable. Breaking that contract is very bad.
  5. Maybe? It's your hobby. I would recommend not making both available. It will be easier to implement correctly and completely if you keep things simple.
Lizenziert unter: CC-BY-SA mit Zuschreibung
scroll top