DEV Community

Cover image for Code creation, try it!
Chris Bertrand
Chris Bertrand

Posted on • Edited on

Code creation, try it!

I think we should consider the option of writing code, that writes code for us! Let me explain why.

We love coding, we try to write as much code as possible. LoC is the ultimate measurement of your awesomeness. 😊 But how many of us write code that creates code for us?

We love using tools/frameworks etc to aid our writing of course, but limit ourselves to writing these tools.

I've recently been looking at Storybook to help automate the creation of a demo app for our UI library. Currently, this is a manual task creating pages and implementing the components and variations needed.

I've been told that it's not difficult and doesn't take very long. My first thought was, well why haven't we automated it then?

Related image
But I can sharpen pencils too

Automation seems to have been swallowed by testing. Developers no longer use it as a tool in their arsenal. We’ll happily scaffold using AngularCLI or the alternative! Why not create the scaffolds? Each codebase has a style, and each company does things their own way, so they should create tooling. Let’s end the notion of style guides and lengthy how to’s to follow.

Image result for automation gif

A component has a template and some inputs. You could create a simple config file, be that in JSON, YAML, JavaScript, hell any language you choose that could parse those inputs and create those pages dynamically.

Why do we want to do this ourselves?

Image result for code monkey gif
Anyone can do this!

This sort of grunt work doesn't give us any satisfaction, but writing a tool to do this for us, packaging, styling and deploying it would be awesome. Maybe it's the inherent difference between a web developer and software engineer? I don't know, I've always thought these titles are interchangeable, is this not the case? Is it that JavaScript is not thought of in this way yet?

Yes, Storybook gives us this functionality, and it seems to do a pretty good job at it too. I just worry that we expect everything built for us these days. We seem to have forgotten that we can build them ourselves, exactly as we want. Lightweight, customisable, geared specifically to our use case. Even if we do not, it's at least worth considering no?

I guess this follows on slightly from Bens Post the other week.

How many people do this currently? What are the main positives and negatives from this approach? Would you do it again?

Top comments (16)

Collapse
 
sampathbalivada profile image
Sai Sampath Kumar

I always had a desire to build something of that sort. Although we cannot write up a program to write the logic for us, there's so much of stuff we write just because we need to.

I'm thinking of a place where we talk with a bot(for instance) and tell it about what need and it builds the UI for us.

Collapse
 
chris_bertrand profile image
Chris Bertrand

That's a cool idea, I'm sure AI will be doing something along those lines in the not too distant future. Will be interesting to see how it pans out.

Collapse
 
deepu105 profile image
Deepu K Sasidharan

You should checkout JHipster then.

Collapse
 
chris_bertrand profile image
Chris Bertrand

There are many tools out there, but have you thought about writing one yourself?

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Well, I wrote a major part of JHipster :)

Thread Thread
 
chris_bertrand profile image
Chris Bertrand

Haha, so you did. Sorry, I thought you were trying to push another third-party tool.

So a question with regards to it. Did it start out as an internal tool that was used to create things, that then evolved into something that was decided to go public, or was the aim of this always to be released to the masses?

I'd say the majority of readers don't think the creation of such things is a good idea. Reinventing the wheel etc. What are your views?

Thread Thread
 
deepu105 profile image
Deepu K Sasidharan

It started out as a fun side project by my friend and JHipster founder Julien Dubois which ended up becoming the development platform it is today.

Collapse
 
jillesvangurp profile image
Jilles van Gurp

I think that just about sums up the npm ecosystem. Many poorly reinvented wheels, me too libraries, etc. How about building better tools?

Collapse
 
chris_bertrand profile image
Chris Bertrand

Or contributing to these poorly reinvented wheels to make them able to roll properly?

Some comments may only be visible to logged-in visitors. Sign in to view all comments.