Last active
December 20, 2015 20:09
-
-
Save veganstraightedge/6188411 to your computer and use it in GitHub Desktop.
An idea for a programming language called "Grammar". The idea was to base it on "normal" english as much as possible. No additional work was done on this idea. It's just a brain dump.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Grammar Sketch 1. | |
New Noun Dog from the Animal family | |
Noun:Dog Family:Animal | |
Noun: Dog Family: Animal | |
Noun: Big Dog from Family: Dog | |
Verb: bark | |
at: a volume | |
for: a length of time | |
at: a time of day | |
Civ is a Dog. | |
Civ's age is 12. | |
Civ's color is black. | |
Civ, bark at 10 volume for 10 minutes at midnight. | |
Civ's age is 13. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Grammar Sketch 2. | |
https://gist.github.com/57559c1ea67fb1eff37f | |
# Remember, I'm a comp-sci dummy. | |
# This is just a thought experiment. | |
# It started after I read an oral history of Xerox PARC: | |
# Dealers of Lighting. | |
# The Alan Kay / Adele Goldberg / Smalltalk stuff got me thinking. | |
# The idea is that things are more closely tied to | |
# English grammar, parts of speech, and sentence structure. | |
Noun Dog | |
Verb bark at:volume | |
puts "woof!" * volume | |
end | |
end | |
# obviously, the only real difference above is: | |
# Classes called Nouns. | |
# Methods called Verbs. | |
# All arguments are keywords, | |
# I'm thinking all keywords are prepositions. | |
# Ignore the puts line syntax for now. | |
Noun Dog | |
Verb bark at:volume | |
puts "woof!" * volume | |
/verb | |
/noun | |
# "end" doesn't quite feel right to me. | |
# And I love me some html closers. | |
# Maybe something like /thing to close a thing. | |
# I dunno. | |
# Then there's inheritance stuff. | |
# A Dog is an Animal. | |
# A Cat is also an Animal. | |
# Both Cats and Dogs can run. | |
# Makes sense to share that run codes. | |
# How to do that? | |
class Dog < Animal | |
end | |
# or | |
class Dog | |
include Animal | |
end | |
# I'm sure there's CS lang implementation consequense of both. | |
# Here's some sketches. | |
New Noun Dog from the Animal family | |
Noun:Dog Family:Animal | |
Noun: Dog Family: Animal | |
Noun: Big Dog from Family: Dog | |
# Here's a verb/method sketch. | |
Verb: bark at: a volume for: a length of time at: a time of day | |
Verb: bark | |
at: a volume | |
for: a length of time | |
at: a time of day | |
# One or multiple lines. | |
# Either way, the obvious first issue is: | |
# What happens when a verb has more than one of the same preposition. | |
# Instance variables. | |
# Dog is a noun. | |
# Civ is a particular Dog. | |
# Sketch. | |
Civ is a Dog. | |
# Setting attributes. | |
# One or multiple lines. | |
# Sketch. | |
Civ's age is 12 and color is black. | |
Civ's age is 12. | |
Civ's color is black. | |
# Punctuation is important. | |
# . | |
# ' | |
# : | |
# , | |
# Period to end a sentence. | |
Civ is a Dog. | |
# Apostrophe. | |
# Single quote: | |
# - word <single quote> s | |
# - word that ends in s <single quote> | |
Civ's color is black. | |
Civ's age. | |
# Colon. | |
# Key/value separator. | |
# Key indicator. | |
# In sentences. | |
# And in Noun/Verb definitions or whatever. | |
Noun: Dog Family: Animal | |
Verb Bark at:volume for: length of time | |
# Commas. | |
# For addressing nouns and issuing commands. | |
Civ, bark. | |
Civ, bark for 10 minutes at midnight. | |
Civ, bark for:10 minutes at:midnight. | |
Civ, bark for: 10 minutes at: midnight. | |
# Capitalization. | |
# Start of a sentence. | |
# Proper nouns. | |
# Civ is both the start of the sentence and a proper noun. | |
# Dog is a proper noun. | |
Civ is a Dog. | |
# I've only started thinking about "primitives". | |
# I like the HTML names for things better than | |
# the comp-sci names for things. | |
# IMHO: | |
# ordered list > array | |
# unordered list > set | |
# definition list ... hash | |
# dl is not super great | |
# table is good | |
# dictionary is ...meh | |
# HTML doesn't really have names for strings, integers and floats. But | |
# text > string | |
# number > integer | |
# That's about all I've got right now. | |
# Go! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment