bat vs. cat


Bat vs. Cat

I was reviewing some sample projects and wasn’t using an IDE this time, I was at a terminal opening up files using ‘cat’, the epic utility to read files. It’s an epic but boring, it does not have the ability to highlight syntax, everything appears bland, there is no facility to list line numbers. I was searching for a worthy alternative to make things refreshing on the terminal, I stumbled upon ‘bat’, a ‘cat’ with wings.

Some highlights –

Syntax highlighting

bat supports syntax highlighting for a large number of programming and markup languages

Git integration

bat communicates with git to show modifications with respect to the index

Automatic paging

By default, bat pipes its own output to a pager (e.g. less) if the output is too large for one screen.

Drop in replacement

It is exciting to pipe the output to a HTTP endpoint and see a well formatted JSON? How about paging with taif -f and it is formatted well enough? Well it can do all that cat can. 

 Bye 🐈 ,  Hello 🦇 .

https://github.com/sharkdp/bat

Posted in Uncategorized | Leave a comment

Composition vs. Inheritance


I was reviewing Java code, there was some refactoring done, the code had extracted out the “common” functionality to a parent class and introduced two child classes.
 
The immediate question that came to my mind was, “why choose inheritance if all that you wanted was reusing the functionality?”, Yes, it is true, inheritance does offer this functionality, this is standard textbook definition of “uses of inheritance”, but should you use it for solely this purpose?.
 
If the intention was to reuse behavior, then it makes sense to compose the common functionality as a class. Inheritance is essential if there is a hierarchy and behavior is required to be overridden (polymorphism).
 
My preference – “Interface >> Composition > Inheritance”. What about you?

Moral of the story:
Inherit only if you want to override some behavior. Inherit less, interface more.

Posted in Uncategorized | Leave a comment

Financial Debt vs. Technical Debt


Many of the terms and concepts we use in Software come from other domains such as Engineering, Finance, Mathematics, Languages, etc. The word for today is “debt”..

What is Debt?
We borrow money to meet a current need, knowing we have to pay interest for it. This is Financial Debt.
vs.
In software, we borrow time as there is no real money. We do something the easy way to satisfy an urgent need, but it might make us spend more time (or resources) later to fix or improve it. This is Technical Debt.

How is it measured?
The interest, principal and taxes constitute the Financial Debt measurement metric.
vs.
We can’t see or measure technical debt well enough because it is implicit and may not be even known. It is very subjective and hard to quantify generically.

Who pays the Debt?
The borrower must pay off the debt.
vs.
The team on the project will have to pay off the technical debt, but it can make things worse if it is not done.

When do we pay the Debt?
We can pay it back early (foreclose) or regularly (EMI)
vs.
We don’t have a regular time for these things like we do for paying money back. Some teams do, most don’t until a point things become hard to make progress.

The longer the time taken to pay off the debt, the bigger is the “interest”. It applies to Technical Debt too, The longer we keep the technical debt, the more it costs us and the more it affects how our system works and how fast we can deliver on it.

So, why don’t we have a timeline for paying tech debt?

Can’t we dedicate one day per month to pay off the tech debt?

Ideally, you want to be debt free, it’s hard but you could reduce it to a minimum. Focus on every commit you make, spare a thought on the debt.

We need a “Tech Credit Score” too, it will give a good indicator to the project’s tech discipline and the borrowing capacity.

What do you think?

#technicaldebt #debtfree #techcreditscore #techdiscipline

Posted in Uncategorized | Leave a comment

Coding life lessons


Code is read more than it is written, so it must be “readable”,
Code is tested more than it is read, so it must be “testable”,
Code is maintained for a long time$, so it must be “maintainable”.

As a software programmer, your guiding principle must be to –
1. Keep your code “readable” and “testable”, if readable and testable, it is already “maintainable” (almost).
2. Have empathy on fellow programmers 🙂 .

PS: Code is used more than it is tested, so it must “usable” (UI/UX).

$cumulative time spent on reading, writing and testing code.

#programminglife #maintainability #empathy

Posted in Uncategorized | Leave a comment

AI Hallucination Info Graphic


Posted in Uncategorized | Leave a comment

Good job Microsoft Edge, nicely done AI (assistant) integration !!


When reading a web page or an article, many time, we need to switch out of the tab to find out what a specific word means, What if, we can get the information inline? No more context switching allowing you to focus on the content much better. It does make the reading experience so much better. Try it out, Just ask your assistant 😎 .

Figure 1: Search Integrates with AI Assistant

No need to context switch anymore, when you are reading a PDF within Edge. oh, why would you read a PDF on Edge?, “Why not”? if it makes your reading experience seamless.

Figure 2: Copilot settings, how nice!

Figure 3: Ask for what you want from your assistant!

Microsoft Edge for its AI (assistant) integration, allows users to get information about words or phrases without leaving the tab. It shows how this feature enhances the reading experience, especially for PDF files. I would urge you to try out these features, it will certainly improve the productivity.

#MicrosoftEdge #AIAssistant #ReadingExperience #PDF #AskYourAssistant

Posted in Uncategorized | Leave a comment

Try out GPT-4 and DALL-E on Microsoft Copilot for free


Microsoft has a new AI assistant called Copilot. It is like Github’s copilot for IDEs, ChatGPT from OpenAI, but an application made for Windows 11. It also works on Mac, iPhone, and iPad. Microsoft has made special keyboards with a Copilot button. Copilot can help with Paint, Photos, Snipping tool, and more. I like the approach Microsoft is taking with its integration, AI should be part of the OS/platform, not each app. I think the OS will provide AI as a service in its SDK/framework, and all apps can use it.

How is “Copilot” different from its competitors? The popular AI chat application “ChatGPT”, offers GPT-3.5 for free use. GPT-4 is available to paid users on its platform. “Copilot” is changing that and offering GPT-4 for free, it is a more advanced model trained with data up to 2023 and includes support for images and voice. The key differentiator with the “Copilot” offering is the integration of image generation based on text prompts (powered by DALL-E).

I tried the GPT-4 in Copilot, here is what I found.

First I tried the image generation capabilities (text to image). Next I tried the image analysis capabilities (image to text). You can observe for yourself the outputs are not satisfactory, off course it is still an assistant !.

Text to Image Generation

Step 1: “generate image of a programmer fixing a bug bounty hunting” (“bounty hunting” was prompted by auto complete, so I went ahead with that).

Images generated for the prompt

Leaving this (“bounty hunting”) out leads to different outputs such as the below.

Images generated when prompt didn’t have “bounty hunting”

Step 2: I provided some feedback to GPT “the generated image is very cartoony generate more real images please”. It acknowledged positively the feedback, let’s see what it did.

Step 2: Feedback accepted ! yay!

Step 3: Results, you can see for yourself, only one 2/4 look like real humans, also notice, it has more “bugs/insects” now.

Step 3: GPT output after working on the feedback

Step 4: I ask again, “these images have lots of bugs or insects can you reduce them”. The results appear, and its worse :-(.

Step 4: Reduce the bugs in the image prompt

Step 5: I asked again in despair, no improvement, it has lost the context now fully :-0.

Step 5: Fix the image please, GPT what have you done?

TLDR; Here is everything put together

GPT-4 Text to Image Generation (animated)

Image to Text Generation

I fed back one of the images it had generated, and expected it will tell me “bug fixing, bounty hunting” etc.. The output was nothing close to that..

Summary

GPT-4 and DALL-E is great, but not perfect, offcourse it is just an “assistant”, it cannot replace human intelligence and judgement. It is only regurgitating, what it has learnt merely by prediction. The technology is not ready for prime time.

Posted in Uncategorized | Tagged , , , , | Leave a comment

Optimizing Maven Builds: My go-to Plugins and Performance Boosters


Maven Lifecycle

Maven is like a must-have tool for Java developers—it helps with building and managing projects. It makes building, testing, and deploying Java apps a breeze using a simple project object model (POM).

What is that super popular command that every maven project user uses? mvn clean install or mvn clean verify?. The second argument to the mvn command, is one of the lifecycle phases that appear below. You must know the important ones at the very least and what they are responsible for. More about it is here.

Maven lifecycle phases

Maven Plugins

The magic of Maven is in the plugin, the model gives developers the power to supercharge their projects. The plugins bind to one or more of the lifecycle phases shown above. As an example, the compiler-plugin is binding itself to the compile and test-compile lifecycle phase of the build process. The binding means that the plugin executes its activity (goal) when that phase is reached.

Maven plugin – lifecycle binding

Tip: you can use mvn buildplan:list to view the plugin bindings to various lifecycle phases on your POM. I am listing few important Maven plugins from my experience that every java developer must be aware of.

My favorite Plugins

Sl. No.Plugin NameDescriptionConfiguration Options
1Compiler
(default plugin for compiling java projects)
It is the default plugin for compiling java projects

It is configured for incremental builds automatically.

Tip: there is no need to use clean every time. just mvn install works.
We need to provide source and target java settings.

We need to provide certain instructions to the compiler such as -Xlint:unchecked

2Dependency enforcerIt helps enforce project constraints and best practices by defining rules.

Tip: it binds to validate phase by default, you should be able to detect problems before compilation.
We want to ensure the project complies with certain standards or conventions.

We want all dependencies in the project (multi-module maven) to have the same version, different versions f the dependencies within the same project leads to runtime issues.

We want to set the “required” versions for dependencies, plugins, OS so all developers use the similar tooling.
3JacocoJava Code Coverage (JaCoCo) a popular tool for measuring and reporting code coverage in Java applications.

Tip: You can set coverage thresholds
We to understand how much of your codebase is covered by tests, identifying areas that may need additional testing.

We have to measure code-coverage across Unit and Integration tests.

We need a HTML/XML report on various code coverage metrics, including line coverage, branch coverage, and cyclomatic complexity.
4FailsafeFailsafe Plugin is responsible for running the integration tests that require the application to be deployed or started.

Tip: The Failsafe Plugin supports parallel execution of integration tests, which can significantly reduce the overall build time, especially when dealing with a large number of tests.
We need separation of Unit and Integration tests, that allows for different configurations and handling of test resources.

We need to configure the various options, such as the test classes naming pattern, system properties for the test JVM, test failure behavior on integration tests.
5SurefireSurefire plugin is responsible for running unit tests written in Java.

Tip: The Surefire Plugin supports parallel execution of unit tests, which can significantly reduce the overall build time, especially when dealing with a large number of tests.
Surefire allows you to set system properties for the test runtime environment. This is useful for providing configurations or parameters to your tests.
6OWASP dependency checkerThis plugin integrates the OWASP Dependency-Check tool into the build process.

The OWASP Dependency-Check tool can identify and report known vulnerabilities in project dependencies.
It helps you proactively manage and mitigate security risks associated with third-party libraries used in your project.

Tip: We can view results in a graphical user interface (GUI) allowing you to visualize and explore vulnerability data through a user-friendly interface.
We need to Identify and report known vulnerabilities in third-party dependencies (it can also work offline).

We can configure it to include or exclude certain dependencies, set vulnerability severity thresholds, and define the format of the generated reports.

7CheckstyleCheckstyle is a tool used for static code analysis in Java.

It helps developers adhere to a set of coding standards and best practices by analyzing the source code and identifying violations against a predefined set of rules.

Tip: You can use the Google styles file or Oracle/Sun styles file
We can configure the plugin to cover a wide range of aspects, including naming conventions, code formatting, code complexity, indentation, whitespace, Javadoc comments, naming conventions, imports.

8Spotless Spotless helps maintain code style and formatting consistency across your project by automatically formatting source code files according to a set of rules. It can support incremental processing

Tip: use palantir java format for formatting of Java code that respects java lambdas and formatting.
We can configure how the source code files should be formatted, such as indentation, line length, and other stylistic conventions.

We can configure spotless to pre-process files before applying formatting, which is very useful for adding “copyrights”, fixing whitespaces and line endings.

9PMDProgramming Mistake Detector (PMD) is a source code analyzer that detects potential issues, errors, and bad practices in Java code.

Tip: You can fail the build on any violations
We can use/configure the built-in rules covering areas such as code style, potential bugs, and performance issues.
10maven profilerA time execution recorder for Maven which log time taken by each mojo in your build lifecycle.Detect issues with your slow builds
Top plugins to have for all Java Projects

Exhaustive list of plugins appear in here https://maven.apache.org/plugins/index.html

Performance Booster

In my experience with Gradle (Android) builds, they are very fast and performant. A little bit of digging into maven eco-system reveals that the “gradle good” is also being brought into Maven to make it more performant and fast under the hood.

maven-build-cache

The build cache extension specifically addresses scalability challenges in large projects. It ensures that Maven builds scale efficiently by implementing incremental execution and facilitating the selective building of sub-parts within a larger project. This approach allows developers to work on specific modules without the need to build and install dependencies from the entire project, resulting in improved build performance for large-scale projects. I have observed build times, decrease by 10-20%

see more https://maven.apache.org/extensions/maven-build-cache-extension/getting-started.html. Also available – https://github.com/takari/takari-smart-builder, seems like a similar project to me.

mvnd

The Maven Daemon is a long-running background process that stays active between consecutive Maven builds. Its purpose is to retain certain components in memory, avoiding the need to reload them with each build, thus reducing startup time.

You need to switch to using mvnd instead of just mvn. I have observed build times decrease by 20-30%.

Summary

  1. Lifecycle is a sequence of named stages.
  2. Phase is stage in the build process which may or may not execute an action.
  3. Plugin is an artifact with one or more goals.
  4. Goal is an action that can be executed.
  5. Every Java project must have plugins around code quality, security, dependency, styling, test coverage and execution in addition to the core plugins.
  6. The speed of maven builds can be improved, when a maven build-cache and daemon (mvnd) are used.
Posted in Productivity, Uncategorized | Tagged , , , , , , , , , , , | Leave a comment

OpenLens – k8s management made easy


Kubernetes, often referred to as k8s, is a highly intricate and complex system. It can be quite overwhelming to fully comprehend and grasp the inner workings of this technology. To address this complexity, there are numerous certification courses available for individuals interested in expanding their knowledge and proficiency in using Kubernetes.

In today’s world, it is expected for programmers to possess skills in designing and deploying their code on such sophisticated systems, often under the umbrella of DevOps. One may argue that while broadening one’s skillset can bring versatility, the famous quote on such generalists – “Jack of all trades, master of none” is worth discussing separately.

A well-designed user interface (UI) can effectively minimize the requirement to memorize commands and options, consequently reducing stress levels for developers and enhancing overall productivity. Previously, I utilized the Lens IDE until it underwent a change in its licensing model. As a result, I transitioned to using “OpenLens” instead. While I acknowledge that IntelliJ IDEA offers many similar features, I personally find the user experience less immersive due to the limited screen real estate it provides and lack of some important feature I use often.

I will look at OpenLens from a Developer perspective – as a developer, I look at the bare minimum Ops required to get my code to work. In that regard, the setup, deployment and monitoring of the tools that I use should not affect my productivity, often new tools promise improving productivity but they don’t.

Setup

Zero configuration is required as it utilizes the existing .kube/config. If you are using the CLI, it is already available to you. In case you do not have one, you can swiftly initialize it by following the provided instructions here.

Obtain the appropriate binaries for your operating system from this location. The binaries offered in this repository are derived from the Lens IDE project K8s Lens.

The following sections will discuss the standard “Operations” guide for a developer. I will now elaborate on how OpenLens assisted me in tasks such as deployment, administration, and monitoring of services deployed on Kubernetes.

Deployment

OpenLens streamlines deployment workflows by providing a centralized location for managing and deploying applications. You can create and manage Kubernetes resources, such as deployments, services, and ingress, directly from the interface. This simplifies the deployment process and reduces the need for command-line interactions.

In place editing of deployments

This is a very good feature, you can change deployments in line and apply the changes. Off-course you need to know what you are changing 🙂.

Helm integration built in

The integration between OpenLens and Helm simplifies Kubernetes application deployment by offering a unified platform for Helm repository management, chart exploration, values configuration, deployment initiation, and real-time monitoring of Helm releases.

Administration

OpenLens allows administrators to manage multiple Kubernetes clusters from a single interface. It also provides administrators with a visual representation of the cluster`s configuration, making it easier to understand and manage complex configurations.

As a developer, I often find these features are very useful – Secret, ConfigMaps, Services, Ingress, Port Forwarding, Events feature.

Secret Management

Look at how easy it is to view secrets, no more multiple commands and decoding. You can copy cleartext passwords. The experience is similar with ConfigMaps.

Port Forwarding

Port Forwarding is so easy, click on the Pod you want to port forward, set the port and you are done. You can start, stop and delete the config from the Port forwarding tab easily. Best of all, It starts port-forwarding automatically as soon as you are connected to the cluster.

Monitoring

OpenLens provides administrators with real-time monitoring capabilities, allowing them to track the health and performance of clusters. This includes insights into resource usage, pod status, and other critical metrics.

Monitoring Dashboard

The “Monitoring Dashboard” above is very useful to look at a high level how your cluster is doing, it has quick links to the information you might be interested in.

Pod Config/Runtime Monitoring Options

Some of the options I use the most are (see figure above) –

  1. Attach to the Pod – attaches to the running pod so you can look at the console outputs (‘kubectl attach ..’)
  2. Start a Pod shell – attaches to the running pod and opens a shell on it (‘kubectl exec -it ..’)
  3. Show Pod logs – view the logs emitted by your service equivalent to (‘kubectl logs ..’)
  4. Edit deployment – edit your deployment YAML, only few like yaml (seriously, spaces matter?) I don’t ! (‘kubectl edit …’)
  5. Delete the pod – kill your deployment pod (‘kubectl delete …’)
  6. Inspect environment variables – Every developer needs this for sure to check what is set into an env. variable (‘kubectl exec -it ..’ , ‘env’ inside the shell or ‘kubectl describe pods …’)
  7. Liveness and Readiness – check how your pods are performing (maybe there is a better command for this – ‘kubectl describe pods …’, look at the events sections)
  8. View Volumes (not shown in the picture) – view attached volumes on your pods (‘kubectl describe pods …’)
  9. View Events (not shown in the picture) – view events on your pods, useful when you need to find out why a pod is in ‘crashloop’. (‘kubectl describe pods …’)

Extensions and Plugins: OpenLens can be customized by installing extensions or plugins to meet specific requirements, integrating additional features or tools into the IDE.

One extension that is missing as a standard, is to view the Pod logs, it can be installed easily as an extension from here. Checkout other extensions that you might interested in. I have the following installed “@alebcay/openlens-node-pod-menu”, “@andrea-falco/lens-multi-pod-logs”.

Let me know your experience on the tool, It really helps me, no more command fiddling, command aliases and switch options 😎.

Posted in Productivity | Tagged , , , , , , , | Leave a comment

Top Technology Podcasts


When you don’t have sufficient time to read and update yourself, what do you do? I listen to updates !. It requires you to multi-task, which itself can be daunting to begin with. As with all things, you need to give some time for it to adjust and it slowly it becomes a habit.

The delivery of information via audio does have its drawbacks, it requires that the listener follow the story in apt attention so as to not miss out on the details, however, some of the podcasts are not very information intensive and are mostly FYI (For Your Information) and FYR (For Your Reference) type.

Favourite Podcatchers

  1. Google Podcasts – very easy playlist management for podcasts
  2. Apple Podcasts – will miss Google Podcasts, this is a suitable replacement.
  3. Spotify – Playlist management for Podcasts is broken/too complicated in my opinion

My Playlist

I have built this playlist after over the years, it is includes shows on general technology news, security, software engineering, IoT, AI and programmer lifestyle.

News

NameMy opinion
This Week in Tech Listen to top tech journalists and pundits in a round table discussion on the latest trends in tech.
WSJ Tech News BriefingCrisp reporting not very broad coverage
Daily Tech News ShowNicely presented, sometimes the coverage is on a broad range of topics
Technology News

Security

NameMy opinion
Smashing SecurityHilarious take on some of the security issues
Security NowWeekly, news and reports on ransomware, viruses, cyber espionage, hacking, etc.
Security

Software Engineering

NameMy opinion
Software Engineering RadioVery detailed interviews with people working in the field of software engineering
Coding BlocksDetailed discussions, perspectives on software programming topics in a very informal way. Some of them are very biased towards .net technologies.
Kubernetes Podcast from GoogleEverything about Kubernetes like General updates on k8s releases, new features, deep dive discussions with experts.
A Bootiful PodcastInterviews with people from Spring team, Spring Security
Tech Lead JournalInteresting perspectives from engineering leaders, industry bigwigs.
The Changelog: Software Development, Open SourceWeekly news and updates, followed by detailed technical interviews
Software Engineering

IoT and AI

NameMy opinion
The TWIML AI PodcastVery detailed interviews with great people working in the field of AI. Some of the topics are very difficult to understand on a podcast.
IoT Podcast: Over the AirVery detailed discussions on IoT devices and general updates on the recent trends in the field.
IoT and AI

Programmer Lifestyle

NameMy opinion
The Happy EngineerOvercome burnout, be happy, get tips and tricks for a good work life balance.
Simple Programmer PodcastGet career advice, get inputs on various soft skills
Lifestyle

Share your playlist if you can, let me know your feedback. Happy listening.

Posted in general, Productivity, Uncategorized | Tagged , , | Leave a comment