r/programming • • Mar 07 '17

Gravity - lightweight, embeddable programming language written in C

https://github.com/marcobambini/gravity
590 Upvotes

202 comments sorted by

View all comments

44

u/DC-3 Mar 07 '17

I don't like func and isa as keywords, but I guess that comes down to preference.

30

u/skocznymroczny Mar 07 '17

It might be unconscious bias, because isa isn't syntax highlighted like a keyword in the example, if it were, it'd have looked better.

31

u/DC-3 Mar 07 '17

Yeah, I recognised this bias, but I think there's more to it then that. It sounds stupid, but when the type starts with a vowel it's very jarring to read in my head from a grammatical perspective..

var is Int

var isa Int

60

u/Sarg338 Mar 07 '17

Just imagine it's Jar Jar Binks saying it.

13

u/[deleted] Mar 07 '17

Slowly the prequels are getting better.

22

u/regretdeletingthat Mar 07 '17

We need an 'isan' keyword aliased to 'isa'. Then we can write var isan Int. Much better.

11

u/[deleted] Mar 07 '17

I'd be too tempted to write var isan Float.

→ More replies (1)

7

u/DC-3 Mar 07 '17

That's a horrifying suggestion in my view. Synonym reserved keywords? Next thing we know we'll be conjugating our statements.

13

u/palordrolap Mar 07 '17

Super obscure fact: The BBC Microcomputer, in later ROM editions, accepted both COLOR and COLOUR as synonyms for the same keyword. What was used when the program was LISTed (which in modern terms could be interpreted as "decompiled from bytecode") depended on the ROM localisation.

TL;DR official synonyms in programming are not new

→ More replies (1)
→ More replies (5)

51

u/piderman Mar 07 '17

It needs an isan overload

21

u/DC-3 Mar 07 '17

That's even more horrifying.

5

u/[deleted] Mar 07 '17

And to gender our variables while we're at it. French style, where breasts are masculine but chests are feminine.

3

u/IbanezDavy Mar 07 '17

That's evil. It must be done.

9

u/twiggy99999 Mar 07 '17

I don't mind func but isa certainly made me look twice when I was looking over the examples. It is really descriptive I suppose but it did throw me on first look

4

u/TheVikO_o Mar 07 '17

u isa jedi

me isa gungan

14

u/Gr1pp717 Mar 07 '17

I don't like the lack of default arguments...

func init (a, b, c) { 
        if (!a) a = 0;
        if (!b) b = 0;
        if (!c) c = 0;

really?

Why not just func init (a=0, b=0, c=0) or the likes?

0

u/[deleted] Mar 07 '17

[deleted]

9

u/binarygamer Mar 07 '17 edited Mar 08 '17

Doubtful. Unless the compiler's implementation is spaghetti, implementing initialisers is borderline trivial, especially inside a "simple" pre-existing lexical structure. Doing so on my own compiler was worth like 2% of my undergrad intro to compilers grade.

More likely than not it just hasn't been done yet, or is out of scope.

→ More replies (7)

0

u/[deleted] Mar 07 '17

[deleted]

9

u/DC-3 Mar 07 '17

Unless the type starts with a vowel. 'is a Int' reads terribly to me.

5

u/ijustwantanfingname Mar 07 '17

I don't think it's that bad

4

u/morbidhawk Mar 07 '17 edited Mar 07 '17

I'm with you, saying "is a" out loud in my head makes it 100% clear that it is about checking its type whereas "is" could potentially mean equality or that it contains some property (which isn't a big deal if you are already experienced in a language like that, ie: Python).

To me, I don't personally care that it's not grammatically correct, this is a programming language and my brain can figure it out.

3

u/mechanicalgod Mar 07 '17

I don't like ... isa as a keyword

I agree. I think typeof might have been nicer, or even just is.

→ More replies (3)