1

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

closed as too broad by user7043, Telastyn, Doval, kevin cline, JeffO Sep 16 '14 at 19:12

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    There are some real benifits to static typing, but also some downsides, in some ways it depends on how expressive your type system is. the Type systems of most OO langauges are pretty basic, and then you get stuff like Haskell, Agda and such which just do crazy things with types. I would suggest doing some real reading on types if you want to go there – Zachary K Sep 16 '14 at 17:55
  • 4
    #1 and #2 are high octane flame bait. #3 is bad subjective aside from a few objective criteria (such as "can it be parsed easily"), and #5 is under-specified and possibly too subjective. – user7043 Sep 16 '14 at 17:56
  • 3
    +1 for delnan's points, plus I don't see any question about type inference... – Telastyn Sep 16 '14 at 17:59
  • @delnan I wouldn't say #2 is high octane flame bait. The answer is simply "yes". Asking if the pros outweigh the cons would be bad though. I agree with the rest of your points too. – Doval Sep 16 '14 at 18:12
  • 3
    Type inference != dynamic typing. For example, many (most? all?) functional languages use static type systems, but they also mostly use type inference. – Dan Lyons Sep 16 '14 at 18:15
3

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.
  • Thanks for your answer! It was exactly what I was looking for! – Francis Sep 16 '14 at 18:23

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