Computers writing code… not humans?.
Generative Coding is concerned with reducing the time [chronos] and effort [prospátheia] required to write software, by using input supplied by the developer and transforming it automatically into code the computer can understand with minimal keyboard intervention. This is an introduction to what Generatron (http://www.generatron.com/) does.
High School… check!, now what’s next?
After high school and after dropping out college (for a while), I started ( at my mother’s behest) taking a few courses in computer programming.
While learning how to write Dbase III programs, a question popped in my mind:
“Can you write a computer program to write computer programs?”
How could I communicate to the computer what I intended to build, without typing a lot, and it would write the source code I needed. One of my teachers mentioned that Dbase itself was written using something called ‘C language’.
Long story short I end up learning C and was able to reverse engineer the structure of the “.dbf” to read the tables and the fields, and then write code i could use to display fields on a screen, and save the data.
Since then I have written many different generators, targeting different languages and platforms, including Generatron. A question to get us started
Can we reduce the time [chronos] and effort [prospátheia] it takes to write software?
That is a question that developers, project managers, stake holders will often ask, and has been approached in many ways, sometimes adding more “brains and hands” seems to be the logical answer.
Software developers have come up with many ways of reducing the time and effort it takes to write a software system, to mention a few:
Using better tools (compilers, IDE, choosing the best programming language for the job), writing code that is clean,modular, scripts to automate tasks, using libraries and frameworks. And then there are code generators, or Automated Coders as we will call them.
As of today, software creation is “tightly coupled”, inextricably linked, to our keyboards and mouses. This is how the thoughts in our brains are transformed into something computers can understand and execute, and it is a relatively slow , error prlorne, I mean error prone process.
What is a code generator?
Code generators or generative coders are the YES answer to the “Can you write a computer program to write computer programs?”.
Generative Coders have existed for decades in many shape of forms, inside IDEs, on the command line, inside programming languages, compilers and as specialized products.
Lets define a generative coder’s purpose:
To help a developers write software in less time [chronos], with less effort [prospátheia] by automating the process of creating code.
An input (ideally, smaller than the final output) is taken and then transformed into code that is useful and meaningful to the developer and the computer.
The input can be: a database, other source code, command line commands, UML documents, YAML documents, anything a computer can read.
Boiler plate Code and Scaffolding.
Let’s introduce a couple of concepts, from their Wikipedia entries.
In computer programming, boilerplate code or boilerplate is the sections of code that have to be included in many places with little or no alteration. … i.e. the programmer must write a lot of code to do minimal jobs.
The need for boilerplate can be reduced through high-level mechanisms such as metaprogramming (which has the computer automatically write the needed boilerplate text), convention over configuration (which provides good default values, reducing the need to specify program details in every project) and model-driven engineering (which uses models and model-to-code generators, eliminating the need for boilerplate manual code) https://en.wikipedia.org/wiki/Boilerplate_code.
Scaffolding is a technique supported by some model-view-controller frameworks, in which the programmer can specify how the application database may be used. The compiler or framework uses this specification, together with pre-defined code templates, to generate the final code that the application can use to create, read, update and delete database entries, effectively treating the templates as a “scaffold” on which to build a more powerful application. It is usually used by company to for creating as a web-base program. (https://en.wikipedia.org/wiki/Scaffold_(programming))
Source code scaffolding is the de facto answer approach to reduce how much boiler plate code a developer needs to actually type on a keyboard.
Several things a can be automated, and usually include: a) Creating a project and/or folder and file structure require by a framework, b) creating default configurations, c) prepare automated testing, and many more.
What’s out there
The approach and scope of what they do varies, and go from visual oriented editors to command line aids, from full applications to starter kits. Not to be immodest lets see who other than Generatron are doing work on this space. The list is not, by any means, exhaustive. You can do a search on twitter by the following hashtags: #appgenerators or #codegeneration, and will find many, many applications
Yeoman Generators (http://yeoman.io/)
Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.
To do so, we provide a generator ecosystem. A generator is basically a plugin that can be run with the `yo` command to scaffold complete projects or useful parts.
Apache Cordova (https://cordova.apache.org/)
Mobile apps with HTML, CSS & JS
Target multiple platforms with one code base
Free and open source
Ionic Framework (http://ionicframework.com/)
Free and open source, Ionic offers a library of mobile-optimized HTML, CSS and JS components, gestures, and tools for building highly interactive apps. Built with Sass and optimized for AngularJS.
Runs on top of Cordova and generates even more stuff, also provides out of the box UI components.
On the backend
Ruby on Rails (http://rubyonrails.org/)
Web development that doesn’t hurt
Ruby on Rails® is an open-source web framework that’s optimized
for programmer happiness and sustainable productivity. It lets you
write beautiful code by favoring convention over configuration.
It also inspired some of the *ils frameworks below.
Grails Framework (https://grails.org/)
Grails is a powerful web framework, for the Java platform aimed at multiplying developers’ productivity thanks to a Convention-over-Configuration, sensible defaults and opinionated APIs. including integrated ORM, Domain-Specific Languages, runtime and compile-time meta-programming andAsynchronous programming.
Grails is one of our favorite tools, after all Generatron has been rewritten using Grails. A simple and powerful backend can be written in a matter of minutes, no kidding. Latest version comes equipped with ‘profiles’ that lets you even greater control of what is generated out of the box.
Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture.
This is a NodeJs based framework, has nice ORM features, also allows you to quickly create REST based webservices.
Visual, Drag and drop component based, application building.
Treeline makes it easy to build custom, high-performance apps for Node.js. It is designed for building practical, enterprise-grade backends in a matter of hours — not months.
This comes from the creators of SailsJS, and takes a visual approach to building apps.
The modular backend platform
for web developers
Create web applications without writing tons of backend code
They have quite a few tutorials on how to write, popular websites clones (instagram, twitter, etc.) using their tools.
Generators can be general purpose (Autocode http://crystal.sh/) on the languages, platforms they target, Or very specific here is one used to aid in creating code for Unity3d game engine,https://github.com/sschmid/Entitas-CSharp