Discuss Scratch

s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

Update: online demo of bloP/blockC available at https://sites.google.com/site/blocklanguages/blockc.


Hi Everyone,
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.

You can try the line demo at https://sites.google.com/site/blocklanguages/blockc.



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):

Modifications to Snap:
- 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:

Core modifications:
- 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

UI modifications:
- 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 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.

Last edited by s_federici (Sept. 23, 2013 10:48:07)

Poemon1_REMIX
New Scratcher
100+ posts

bloP - Building Your Own Block Language

This looks really cool, but I'm kind of confused. Is it a visual drag and drop version of C++?
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

Poemon1_REMIX wrote:

Is it a visual drag and drop version of C++?

Thanks for asking! bloP can be used to BUILD drag and drop versions of your favorite programming language. Then you can lock the environment so that the users of your language can create programs built with the blocks of your progamming language but cannot remove or delete things that could break your programming environment.

For example I have implemented a block version of C++ as a SnaP project. But after opening my C++ in Snap my users could break the language by removing or modifying the custom blocks and sprites I created.

That is why I designed bloP: when my C++ language (blockC) is open in bloP, the environment is locked by removing all possibilities of modifying the blockC programming language, but still allowing users to build C++ programs by snapping together the custom blocks I created.

If you are not satisfied with blockC, by knowningly unlocking the bloP environment you can switch to Snap so that you can modify blockC or you can create a completely new block programming language.

So, what do you think of bloP? Why don't you download it and let me know what is your valuable opinion about it?



Poemon1_REMIX
New Scratcher
100+ posts

bloP - Building Your Own Block Language

s_federici wrote:

Poemon1_REMIX wrote:

Is it a visual drag and drop version of C++?

Thanks for asking! bloP can be used to BUILD drag and drop versions of your favorite programming language. Then you can lock the environment so that the users of your language can create programs built with the blocks of your progamming language but cannot remove or delete things that could break your programming environment.

For example I have implemented a block version of C++ as a SnaP project. But after opening my C++ in Snap my users could break the language by removing or modifying the custom blocks and sprites I created.

That is why I designed bloP: when my C++ language (blockC) is open in bloP, the environment is locked by removing all possibilities of modifying the blockC programming language, but still allowing users to build C++ programs by snapping together the custom blocks I created.

If you are not satisfied with blockC, by knowningly unlocking the bloP environment you can switch to Snap so that you can modify blockC or you can create a completely new block programming language.

So, what do you think of bloP? Why don't you download it and let me know what is your valuable opinion about it?



Sounds cool! I'll downloda it!
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

Update: I made the picture visibile. Thanks a lot Poemon1_REMIX!
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

The online demo of blockC is now available! Try it at https://sites.google.com/site/blocklanguages/blockc.
BigBlueBlock
Scratcher
500+ posts

bloP - Building Your Own Block Language

How do you open the .xml file in bloP
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

BigBlueBlock wrote:

How do you open the .xml file in bloP

If you downloaded the bloP/blockC package, just use the “open” option of the “File” menu (the white page button at the topleft of the page). For any other question, just ask!

Please, let me know what you think of this tool! Thanks in advance
BigBlueBlock
Scratcher
500+ posts

bloP - Building Your Own Block Language

s_federici wrote:

BigBlueBlock wrote:

How do you open the .xml file in bloP

If you downloaded the bloP/blockC package, just use the “open” option of the “File” menu (the white page button at the topleft of the page). For any other question, just ask!

Please, let me know what you think of this tool! Thanks in advance
It crashed. Windows 8.1 beta and Firefox 24.0
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

BigBlueBlock wrote:

It crashed. Windows 8.1 beta and Firefox 24.0

Yep. As explained in the top post “blockC crashes Firefox”. Could you please try to open it in Chrome? Thanks in advance!

NOTE: bloP instead should run fine in Firefox. If you are interested, I'm preparing a simplified version of blockC (just INT data). Just let me know
shadowmouse
Scratcher
100+ posts

bloP - Building Your Own Block Language

Sorry if this is a stupid question but does blockC compile? And if so is it as fast as normal c++? Also, is there a picture to text converter so that if it is much slower you could ‘write’ code in this (easier) and then copy and paste it into an IDE which would run it (faster).
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

shadowmouse wrote:

does blockC compile? And if so is it as fast as normal c++? Also, is there a picture to text converter so that if it is much slower you could ‘write’ code in this (easier) and then copy and paste it into an IDE which would run it (faster).

As of now, blockC is only interpreted. So it is much slower than normal c++. This is not a problem with blockC, as it is primarily designed to make learning c++ easier before moving to a textual IDE. But your question is really important as, thanks to the new “codification” features of Snap that Jens Moenig added last summer, now converting Snap (and then bloP) blocks to their textual version is really simple to be implemented. Are you interested in this feature? If so, let me know, as I could add this development to the bloP/blockC pipeline.

Anyway, I would be really interested at knowing what you think that the strengths/weaknesses of bloP are. Thanks in advance!
shadowmouse
Scratcher
100+ posts

bloP - Building Your Own Block Language

Yeah! I think that being able to write code in a scratch-like environment, but with the power and speed of c++ (via an IDE) would be brilliant. The only problem that I can think of is that it might become difficult to write very large scripts as it might become very laggy like scratch does. But the lack of spelling/syntax errors is brilliant! Another question, can it use images?
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

shadowmouse wrote:

The only problem that I can think of is that it might become difficult to write very large scripts as it might become very laggy like scratch does

Yes, this can happen. Managing large scripts in Scratch or Snap (and then in bloP) can be difficult.

shadowmouse wrote:

the lack of spelling/syntax errors is brilliant!

That is why I'm proposing bloP as a tool to develop “educational” block versions of standard textual languages. Performance for this tool is not the main goal. The focus is on the possibility of building blockJava, blockPython, etc or your own perfect-for-your-purposes block language. You can use bloP in order to learn the language. Then you can pass to a standard IDE when you got confident with it.

shadowmouse wrote:

Another question, can it use images?

As Scratch (and Snap) can use images, blockC can be certainly augmented with image handling. C++ Standard Library has no support for images. So, let me know what is your favorite library to handle images.
shadowmouse
Scratcher
100+ posts

bloP - Building Your Own Block Language

I'm just learning so I really don't know. I've seen code from SFML before which doesn't look too bad. I'm currently trying to use quincy (an all in one IDE, compiler and graphics library) which uses winBGIm. I think you should have blocks that are just a text input so people can also use libraries that are not included and/or their own header files.
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

shadowmouse wrote:

I think you should have blocks that are just a text input so people can also use libraries that are not included and/or their own header files.

This is something that you can find even in some mod of BYOB. I'm not really sure if this is the right way. Indeed, you would get a lot of flexibility, but you would also loose the syntax check provided by the blocks… what do you think?
shadowmouse
Scratcher
100+ posts

bloP - Building Your Own Block Language

I think put them in a special category just in case people want to include their own header files that let them use things that bloP doesn't have.
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

shadowmouse wrote:

put them in a special category just in case people want to include their own header files that let them use things that bloP doesn't have.

This will be useful if the code is exported and run in an external C++ engine as bloP won't know about how to run the content of those textual blocks inside the IDE. Will this be ok?
shadowmouse
Scratcher
100+ posts

bloP - Building Your Own Block Language

Sounds good. Two things though, can bloP use header files? and I'd put them in the same colour as obsolete blocks so that people know that bloP won't run them.
s_federici
Scratcher
500+ posts

bloP - Building Your Own Block Language

shadowmouse wrote:

can bloP use header files?

I'm not sure what you mean. I'll try to interpret your question: bloP can only run inside the IDE blocks that have been defined by the creator of the block language (for example blockC). So only header files and blocks that are already known can be run inside the IDE. This said, if the “text” block is used to load new headers and for using the functions defined inside unknown libraries, it will still be able to output the correct code so that it could be run in the external engine (for example a c++ engine). Does it answer your question?

shadowmouse wrote:

I'd put them in the same colour as obsolete blocks so that people know that bloP won't run them.

Good idea

Now I would like to know if you tried bloP and blockC and what you think of it. Is it usable? Do you see other important missing features? Thanks in advance!

Powered by DjangoBB