DEV Community

Cover image for Metaprogramming - how to be lazy and reach high levels of productivity

Metaprogramming - how to be lazy and reach high levels of productivity

Mahezer Carvalho on January 23, 2024

I was recently tasked with abstracting a database into an API. The database had a lot of confusing data formatting functions which should also be a...
Collapse
 
syxaxis profile image
George Johnson

When I was 21 ( way back in the 1990s now ) I said to my boss at the time, "You know I'm just very, very lazy, why would I do stuff manually when i can code it up and get systems to work for themselves.".

She jokingly went nuts at me, "You are NOT lazy and you are never, ever to say or think that ever again! It's not lazy, it's working efficiently and more people need to be like you and get this kit to work harder and smarter.".

To this day 30 years later I never use the word lazy to describe smart corner-cutting or efficiency. She was right, 'cos "lazy" makes you think that you're not good enough, "effiency" means you're thinking about working smarter and making best use of your skills and time.

Collapse
 
ravavyr profile image
Ravavyr

damn right.

Collapse
 
valvonvorn profile image
val von vorn

That's the theoretical ideal of programming, popularized by the 1980s generation and maybe obsolete when machine learning will take that part of metaprogramming away from humans. Then we can go beyond metaprogramming and rediscover real creativity again!

Collapse
 
israelrotimi profile image
Israel Rotimi

I was in a similar situation yesterday (Jan 23), I wanted to contact some phone numbers through whatsapp for marketing purposes and I didn't want to populate my phone's contact book unless they showed interest.
So, I decided to make a link out of each number.
I did this by creating a new html file and wrapping some text in an a tag and setting the number as the href value.
After doing the first one it struck me that I could automate this.
I thought of using JavaScript since I was fond of it but used Python instead thinking on the simplicity and filesystem access.
I wrote a python script not more than ten lines to automate the task for me. 💯

Collapse
 
suther profile image
Samuel Suther

I didn't want to populate phone's contact book unless they showed interest.
What does this means? Not yet work with WhatsApp marketing, but it seems to be one point that I must be aware of in future?!?

Would love if you could share some more information about this (e.g. some stuff to read or a link, or an explaination).

Thanks.

Collapse
 
tiuwill profile image
Willian Ferreira Moya

Great article!

This is something that every developer should do. This can save you tons of hours of work. It's a skill and also is really fun. You can use these automations to learn something new too. For instance, if you're trying to learn a new programming language, you can use that new language to create an automation script. The script doesn't need to be the most optmized or clean, just need to save you some time.

Again, that was a great post and can inspire lots of developers to do the same!

Collapse
 
aralroca profile image
Aral Roca

Lazy developers found the better DX solutions, totally agree!

Collapse
 
rlacf profile image
rla-cf

I have this age old saying: "A good developer will go to extreme lengths to be lazy".

As described in the post, you are better off automating boring tasks by building some temporary intermediate tool than by doing the monkey work. So the "go to extreme lengths" here is not trying to get away and not do the work, but to be passionate and innovative to build something so the work gets done for you.

Collapse
 
ooosys profile image
oOosys

If you consequently think about this deeper and deeper you will arrive at a system which had have automated your entire own life for you ... no more Sudoku, no more crossword puzzles, no more cooking, ...
And yes ... it's usual everyday business to create a programming environment and then create another one and then port the programming done in the first to the second one. This will keep you busy ... creating another meta-language to solve the problem of coping with multiple languages you won't run into if not creating the issue in first place. The only way out of this trap I see is to make the English language work as programming language ... I call it the "oOo way" of approaching computing.

Collapse
 
mahezer profile image
Mahezer Carvalho

There is definitely a limit to automation, you should not fly too close to the sun, so to speak.

The main focus of automation is to free your time that's taken up from repetitive tasks so that you can do stuff that you actually enjoy

Collapse
 
suther profile image
Samuel Suther

The main focus of automation is to free your time that's taken up from repetitive tasks so that you can do stuff that you actually enjoy

That exactly the point. There is also a trap of over-engineering.
One kind of over-engineering is to put hours of work into a task that don't repeat and would be solved in same (or less) time.

Also seen this kind of contra-productive automation some times :)
So be careful ;)

Collapse
 
_ndeyefatoudiop profile image
Ndeye Fatou Diop

Great post ! I am actively trying to be lazier

Collapse
 
mahezer profile image
Mahezer Carvalho

Thanks! Automation will give you time to laze around a lot :D

Collapse
 
nitishkr72 profile image
Nitish Kumar

Nope, During that automation you will get another task :D

Collapse
 
tmac profile image
tmac

Used to do this to build a "data dictionary" from SQL Server. There is a hidden or little-known "gem" called "Extended Properties". You can set them at the Database, Table, Column, View, Procedure levels (almost anywhere). So you can create a self-documenting database. This can then be exported via a script into Excel or you can use T4 Templates or something to generate anything you want (classes with comments on properties auto-generated for example).

Collapse
 
sreno77 profile image
Scott Reno

Good article

Collapse
 
mahezer profile image
Mahezer Carvalho

Thank you!

Collapse
 
chrisburkssn profile image
Chris Burks

Thanks for the read I enjoyed it. Now my head is filling up with all types of ideas on how to automate some of my work.
Thanks again!!!

Collapse
 
mahezer profile image
Mahezer Carvalho

Please feel free to share your automation stories! I'd love to hear how I was able to inspire you :)

Collapse
 
kalebbolack profile image
Kaleb Bolack

Honestly a great read, throughly enjoyed; Got the gears in my head turning now!⚙️🤯 I want to hear the next thing somebody decides to automate!

Collapse
 
mahezer profile image
Mahezer Carvalho

I'm really glad you enjoyed it! Feel free to share your automation stories as well! :D