Skip to Content

bloP - Build Your Own Block Language

Ever desidered to build your own educational Scratch-like programming language? Now you can in a user-safe development environment: bloP. Try it online!

Try it online!

 

I have completed a first draft of "bloP", a development environment for block languages. The environment is a mod of Snap (well, to be clear, without Snap the whole project just wouldn't be there... Thanks Jens and Brian for your wonderful environment!). bloP stands for "BLOck Programming". 

 

At the moment I have a ready version of my "block-C" language (a subset of C/C++ implemented as a block programming language) that fully works in bloP. After loading the blockC.xml file in bloP you will see 6 categories of  blocks: Input, Output, Control, Functions, Operators, Variables. In the "C programs" and "C++ programs" sprites you will find working examples of blockC programs. In order to run a program just click on its script. By clicking the green flag, the topmost program of the selected sprite will be run. When you click on a new program, the program that is running (if any) will be automatically stopped.

 

bloP IDE

 

You can download bloP and blockC at http://goo.gl/quglHp. Please, let me know of every improvement you think I could make to the environment in order to make it really useful and easy-to-use for people who want to develop (or use) block languages.

 

WARNING: while bloP runs fine either in Chrome, Firefox or IE, blockC on the countrary is a bit heavy, so it runs fine only in Chrome. I didn't investigate it in depth, but on my PC loading blockC crashes Firefox and freezes IE.

I'm developping a simpler version of blockC (only INT variables and only C instructions). Let me know if you are intersted by dropping a line at http://www.blocklanguages.org.

 

=== How to Startup a block language

To startup the blockC language follow these steps:

1. open bloP.html

2. in File > Open select the blockC.xml file (if during loading your browser tells you that there is a script that is not responding... just wait a little bit)

3. you can run the sample programs that you find in "C programs" or "C++ programs" or you can create your own blockC programs by adding ("+" button) or duplicating a program (rightclick menu) or by using File > New in order to create a completely new blockC program. Just snap together the C/C++ blocks you will find in the Input, Output, Control, Functions, Operators, and Variables categories.

4. save your programs by using File > Save As... The programs will be saved in a new XML file (NOTE: in this version the XML file will include both the programs and the whole definition of the block language)

 

=== How to Modify or Create a block language

To create a new block language, just follow these steps (if you want to modify the blockC language, follow steps 1 and 2 above in order to load blockC in advance):

1. shiftclick the bloP logo and select "Unlock GUI" in the menu

2. show the primitives you need by rightclicking in the palette and selecting "show primitives" in the menu

3. make all icons visible in the corral by rightclicking the corral and selecting "add removed objects back to corral"

4. modify the environment as you like by:

- modifying custom blocks or adding new custom blocks

- renaming categories by righclicking them

- restoring default names and visibility for all categories by rightclicking the category frame

5. When you are done, go back to the bloP environment by shiftclicking the bloP logo and selecting "Lock GUI"

 

=== bloP Philosophy

In order to make the bloP environment safe (that is, you won't be allowed to modify the bloP environment when it is "locked": you won't be able to define new blocks, drag sprites, etc), so that when you write and run your programs you won't risk to impair the environment, I made some modifications to Snap, trying not to change the way Snap works (you should be able to load and run Snap XML files without any modification), such as:

  • you can hide/rename categories (when you hide a category, all primitives of that category will be hidden)
  • you can hide the Stage and the sprites icons in the corral (but you need at least one visible sprite icon in the corral)
  • you have 3 new Control blocks:

              - hat "when loading": the script under this hat is run when a program is loaded in Snap/bloP

              - hat "when running a script": the script under this hat is run in bloP before another script is run (that is when you click on it or you click the green flag)

              - block "run other scripts": this block, used at the end of a script that starts with the "when running" block, runs the script you intended to run when you clicked on it or clicked the green flag

  • you can switch from Snap to bloP (and viceversa) by shiftclicking the logo and selecting "lock/unlock GUI".

When you lock the Snap GUI and switch to bloP you will have a different environment in which:

  • sprites/watchers on Stage are non draggable
  • variable and list watchers cannot be modified
  • by clicking the green flag you run the topmost script of the selected sprite 
  • you can't have programs (sprites) with the same name 
  • you don't see sprite infos such as rotation style and draggability
  • you can't hide/show primitives
  • you can't hide/rename categories
  • "sprites" are renamed "programs"
  • you can't define or remove custom blocks
  • you can't change settings
  • you can't use the cloud storage
  • costumes and sounds tabs are hidden
  • the button to create new sprites by drawing them is hidden 

By shiftclicking the Snap logo you will be able to lock the GUI so that your language users won't be able to impair the environment by doing something wrong. But they will still be able to modify the environment, if they want, by shiftclicking the bloP logo and knowingly unlocking the environment.

 

=== Create your own block language

These features should allow you to develop your own programming language built by blocks. 

 

By shiftclicking the bloP logo you will be able to unlock the GUI so that you will have the full power of Snap (http://snap.berkely.edu) available to develop your own language blocks. 

 

Use the "when loading" and "when running" blocks to define scripts that you need to run at setup time in order to prepare your environment ("when loading" hat) or to cleanup your environment each time a new program runs ("when running" hat). Remember: your users will be able run a new program even before the running program has halted (the running program will be stopped).

 

bloP always runs in "locked" mode at startup so, when you are done, all you need to do is saving your language: there is no need to move back to bloP before saving. Furthermore, when your users will load your language in bloP they won't be able to impair the environment by doing something wrong.

 

=== Comments are Welcome!!!! (and this is just an understatement... :-)

I'm very interested in hearing from you. Really. I'm serious. VERY interested. The present design of bloP is mainly oriented to the implementation of text languages (such as C, Perl, Python, etc) but I'm adding new features, so, if you have any suggestion about what you would need in order to implement your own block language (textual or visual), or you think that you had a good idea on how to improve bloP or you just found a bug, drop me a line at http://www.blocklanguages.org.

 

=== Future Work

I'm working on importing in bloP other block languages I had started to develop in BYOB, namely ASSL (a visual language to design searching/sorting algorithms) and a subset of Berkely Logo. If you want to collaborate to create an extensive library of block languages, please, do not hesitate to contact me at http://www.blocklanguages.org

 

=== Known Problems:

- you can't use single quotes in block names (see "A" block in Operators category. It should be 'A' instead...)

- the comma after the last arguments of a function shouldn't be there... (you can notice that I started working on this in the dialog of the properties of input arguments for custom blocks)

- rings can be really confusing to people that don't know what they are (this can happen to users of your own language that don't have to know Snap in advance). So I'm going to remove them when bloP is in locked mode.

- switching between Snap and bloP is a bit slow (the whole program is saved and then reloaded). I'm planning to speed up this operation together with the operations of loading/saving bloP projects.

- having menu inputs for custom blocks would help a lot to create block languages that are much simpler and clear (you can notice that I started working on this in the dialog of the properties of input arguments for custom blocks)

- watchers on the Stage don't grow or shrink in small Stage or presentation mode

- lists do not scroll to show the last added element

 

FINAL NOTE: bloP is based on Snap version 24/7/2013.