what if everyone wrote a programming language?

what would happen? the literal and obvious answer is that we dont know. but if we allow ourselves to speculate, here are some thoughts springboarded by a few facts and metaphors:

 

  • reality: not everyone is going to write a programming language

i know, but this is speculation. a lot of it is really “what if a lot more people wrote programming languages,” but the question is only fair because i encourage everyone to write one.

 

  • natural selection: most of these languages will not be very good

thats ok; in fact its not even important. if people took a few hours to write a programming language, it is a single lesson that would substantially increase the way they understand programming.

 

  • true scotsman: most of the languages wont even be “real languages”

actually, its nearly impossible to create a “programming language” that isnt a programming language. lots of useful software projects can have scripting engines without creating full-fledged languages, markdown is probably not the very last “standard” of its kind, dont be afraid of being “cute,” because it will be fun.

i made a language that consisted only of the goto statement. it could do 25 different things, and i adapted it from another simple language interpreter someone else wrote. did i mention that i redid their interpreter in my own programming language?

 

  • aiming for the stars: most people cant create a programming language

this is like saying most people cant code. the trick is to make it easier to do. making it easier to create a programming language is something ive been working on for a while. and yes, just like you need things like scratch or basic or logo to get “everyone” programming, you need something simpler if everyone is going to make their own language.

thats not a real problem.

 

  • convergent evolution: too many languages, and no one will know the same one

this isnt true at all. if everyone made a programming language, the features would coalesce into more serious languages. even if a few inspired a new feature (or approach) in serious or educational languages, it would be worthwhile. but although this would likely happen, even if it didnt:

 

  • optimal learning: we should focus on serious languages

i dont agree with this either. first of all, educational languages have made it easier for younger programmers to start earlier and get comfortable with computing. the idea that we can skip this step is like saying we could skip educational programs to introduce young children to reading, because the best time to start learning to read is grade 4.

no one learns how to read “the wrong way,” or how to code the wrong way: thats paranoid nonsense. some people are not good at coding, and other people have not yet learned best practices, but dabbling on a toy piano is not going to prevent you from becoming a skilled pianist or composer.

only in programming is there a fear that early education and practice could somehow “taint” the future student. when there is more (or any) reasonable scientific evidence that this is the case, thats another matter. (even then, its still more paranoid to think it is irreversible.)

 

  • but why? you havent said why…

the reasons vary, so i will give mine.

  • its fun
  • it will make you a better programmer
  • its not nearly as difficult as its made out to be
  • you will better appreciate and understand programming
  • its just one more “programming exercise” worth trying
  • it will inspire you to write lots of other programs
  • i believe it will ultimately push language development forward
  • literacy is not just about reading, but authoring

you can argue against all of those– and i can argue for them. really, my job isnt to convince you to do something you dont want to do; only to make a case for trying it; and to help people that are interested in making it easy enough to actually achieve something.

thats pretty much all i have to say about it for now, i would love to revisit the subject or have other people share their thoughts on the matter.

note that when i talk about “writing a programming language” i am talking about a simple starter language: something that could be done in hours, days, or a week (depending on the level of sophistication.)

i do include writing your own program to compile (probably to another high-level language) or interpret the language; you could also adapt an existing compiler or interpreter.

whether it became a bigger project than that would depend on how much the author got out of the effort. if it was boring and they didnt learn much, i wouldnt necessarily push going forward from there. but if they had fun at all, they could continue with it or write a slightly more enhanced language after that.

if there were a push towards trying, i think a lot of people would realize it isnt that difficult; even if they thought it was something they would never do.

 

 

Advertisements

5 thoughts on “what if everyone wrote a programming language?

    1. thats what fig is written in. here, grab the source for these two versions: https://archive.org/download/Puppy_Linux_Refractapup/fig29.py https://codeinfig.wordpress.com/2016/02/10/fig-3-1-source-code-public-domain/

      python is normally implemented in c, and fig is implemented in python, and you can definitely write a language in python or fig.

      want a start? do a program with command line switches.

      oh, you already have one? ok, now have it process the text in a file the same way it would process the command line switches.

      now add some more features, and some more switches– voila, you have a programming language. (no joke.) now, you can make the way the input is processed increasingly sophisticated, until it even FEELS like a programming language– but it already was by then.

      Liked by 1 person

    2. i spent about 25 minutes writing a programming language for you to play with:

      #!/usr/bin/env python
      # encoding: utf-8
      # a very simple programming language, written in 20-25 minutes, today (feb 2017)
      #### license: creative commons cc0 1.0 (public domain) 
      #### http://creativecommons.org/publicdomain/zero/1.0/
      
      variables = {}
      def repeatprint(p, x): print ((p + " ") * int(x)).rstrip()
      def printsum(p, x): print float(p) + float(x)
      def setvariable(p, x): global variables ; variables[p] = x
      def repeatvariable(p, x): print ((str(variables[p]) + " ") * int(x)).rstrip()
      
      demoprogram = """
      setvariable d 12
      repeatprint hello 5 printsum 5 9
      repeatvariable d 9"""
      
      xp = []
      for p in demoprogram.replace("\r", " ").replace("\n", " ").split(" "):
          p = p.strip()
          if len(p): xp += [p]
      
      build = []
      for p in xp:
          build += [p]
          if len(build) == 3: 
              if build[0].lower() == "repeatprint": repeatprint(build[1], build[2])
              if build[0].lower() == "printsum": printsum(build[1], build[2])
              if build[0].lower() == "setvariable": setvariable(build[1], build[2])
              if build[0].lower() == "repeatvariable": repeatvariable(build[1], build[2])
              build = []
          else:
              """print build"""
      
      # demo program:
      # setvariable d 12
      # repeatprint hello 5 printsum 5 9
      # repeatvariable d 9
      
      # expected output:
      # * sets d to 12
      # * prints hello 5 times
      # * prints the sum of 5 and 9 as a float
      # * prints the value of d, 9 times
      
      # actual output:
      # hello hello hello hello hello
      # 14.0
      # 12 12 12 12 12 12 12 12 12 
      

      its unsophisticated– it takes shortcuts like every command has exactly 2 parameters.

      most languages need recursive parsers to work the way you would probably expect them to. however, you can learn how to write recursive parsers, or you can get an existing one and adapt it to your needs, or you can generate one after learning the parser generator syntax. or you can decide that your first language wont have a recursive parser (or the fancy syntax that it allows) –and i recommend that option.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s