The SKILL programming language augments Cadence core tool
functionality for Virtuoso and Allegro customers. It is also an
important development tool for internal Cadence services organizations
as well as Cadence product development groups. We see the value,
power, flexibility, and elegance of the language as an enabling tool for customizing and enhancing design environments. These
capabilities are made possible by the tight integration of the
SKILL programming language into the Cadence platform.
This post introduces an upcoming series of articles, SKILL for the Skilled,
which will attempt to better enable users to exploit the power and
elegance of this fun and interesting programming language.
WARNING: What you are about to read is HIGHLY OPINIONATED!
SKILL Functions: Short and Clear
SKILL programs are usually made up of functions. A function should be
short, clear, and express intent. Some programming languages force
the programmer to transform the software problem into what the
language can express, rather than allowing the programmer to transform
the language to fit the problem at hand. The unfortunate result is
often that the SKILL program looks like a C program, and is twice to
ten times as long as it needs to be. We'll look at this ability to
transform the language in upcoming articles.
To illustrate the idea that functions should be short and clear, here
are two different implementations of the same conceptual function.
The confusing one (#1) uses an imperative style. Avoid this style.
The second one (#2) uses a functional style. Without sacrificing
clarity, it expresses in two lines what the imperative style expresses
in nine lines. It is clearer, probably easier to debug, most certainly
more efficient computation-wise, and scales better to larger programs.
Implementation #1 -- needlessly confusing
Implementation #2 -- clear and simple
value = abs(x)
if( value < 100
) ; if
) ; prog
) ; procedure
(procedure (abs_less_than_100 x)
(abs x) < 100)
What were the programmers thinking?
What are the problems of Implementation #1? What was programmer #1's
thought process? He was probably trying to think like a Von Neumann
machine -- in terms of an arithmetic unit and moving values around
between registers until the goal is achieved. Programmer #2 was
probably trying to express a mathematical expression.
A more natural way to think
I claim that the mathematical evaluation model is an easier, more
natural way for humans to think than trying awkwardly to think like a
machine that's moving data between registers. Don't try to make
the problem harder than it is.
Some mistakes to avoid
Aside from the two very different ways of thinking, there are several
other issues I have with implementation #1.
SKILL is easy, flexible, powerful, and elegant
- It declares the useless variable:
value. There is
normally no need to declare a value which is used only once.
- It unnecessarily uses
prog/return. There is no
need to use
prog/return if you want to return the value
that is already in the tail position.
- It unnecessarily uses
if/then/else. There is no need
to test an expression for TRUE/FALSE, and thereafter produce the
same TRUE/FALSE using
- It fills up half the screen space with lines containing only close
parentheses. There is no need to put parentheses on separate lines.
Rather use an editor which enforces indentation.
- Its only comments are redundant; and worse, they will probably be
out of date as soon as someone edits the function and forgets to
check all the comments.
The SKILL language is on the one hand easy to learn and easy to use
for simple use-once-and-discard scripting tasks. On the other hand
the power and flexibility of the language is evident when experienced
programmers develop well designed, high quality SKILL based software
applications. The elegance of the SKILL language is often
underestimated. A well written SKILL program is easy to understand,
takes fewer lines of code to implement, and incurs shorter development
times than with most other language alternatives, assuming the
developers understand the tools they are using.
Until now, it has been somewhat difficult to find insightful articles
written about SKILL and how to apply it to day to day problems. I hope
this series of articles enables you to get more benefit and enjoyment
out of the SKILL programming language.