Blockly in Other Languages

1,396 views
Skip to first unread message

Austin Ayers

unread,
Jun 29, 2015, 12:26:12 PM6/29/15
to blo...@googlegroups.com
Hi,
Currently Blockly supports four languages. What steps would I need to take in order to add a new language to that selection? I've been pouring over the files in the generator section and was wondering how I would go about starting this project?

Thanks for your time,
Austin Ayers

Blake

unread,
Jun 29, 2015, 1:15:05 PM6/29/15
to Blockly
Austin,

Assuming you are talking about what Blockly calls "Code Generators" then there are a number of steps required. 
Recently PHP support was added. You can see the changes made in the Pull Request here: https://github.com/google/blockly/pull/98

I'll list them form memory but I hope others can help.
  1.  Create:
    • blockly/generators/<language>.js
    • blockly/generators/<language>/<other files>.js //these are the files that tell blockly how to convert blocks to code
  2. Add the language to the build file: https://github.com/google/blockly/blob/master/build.py#L164-L167
  3. There is a "standard block set" that all of the current languages implement, the definitions of the the blocks are here https://github.com/google/blockly/tree/master/blocks
  4. You can use the Block Factory to generate new types of blocks if needed. https://blockly-demo.appspot.com/static/demos/blockfactory/index.html
I hope this helps you get started.
Blake

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Friedman

unread,
Jun 29, 2015, 1:28:03 PM6/29/15
to blo...@googlegroups.com
It's also worth pointing out that there are additional language generators for Blockly that have been implemented by third parties.  So, if you're interested in a particular language it might be worth searching through the Blockly group archives to see if anyone else has already done it.

-Mark

Austin Ayers

unread,
Jun 29, 2015, 1:29:17 PM6/29/15
to blo...@googlegroups.com
That does help, thanks! Any other tips are greatly appreciated. I'm fairly new to Blockly, and its applications seem diverse.

Austin Ayers

unread,
Jun 29, 2015, 1:43:01 PM6/29/15
to blo...@googlegroups.com
Good idea, unfortunately, I was unable to find the language I'm going to implement. It would have saved me some headache.

Carlos Pereira

unread,
Jun 29, 2015, 4:30:50 PM6/29/15
to blo...@googlegroups.com
Out of curiosity, which language is that?

Burak Bilgehan

unread,
Nov 21, 2016, 4:31:56 PM11/21/16
to Blockly
Hi Blake,

Are the steps you wrote enough for making Blockly generate codes in a new language? I mean, we are trying to make blockly for a new domain specific scripting language and we need blockly to generate the codes in this language. By following those 4 steps will the blockly generate codes in our language? How much work needed on it? I've been researching for it and things seem a little complex for me. Many projects for this task coded in different ways, in general you are right, they add a new "blockly/generators/<language>.js" document and "blockly/generators/<language>/" folder. But even though the structures of .js files are similar, they all have different code parts, which makes me don't understand how to fill the codes. Thanks in advance.
Burak

Zubair Quraishi

unread,
Nov 22, 2016, 8:38:56 AM11/22/16
to Blockly
I made a Clojurescript generator if that is of any use to browse the code:

https://github.com/zubairq/yazz/tree/master/resources/public/blockly/generators
Reply all
Reply to author
Forward
0 new messages