# Another language's API: `null` or `===` in Python, `.strip()`, `None` or `len()` in JavaScript, `null` in Go

*Calls and packages that do not exist*: one of the ways AI coding agents bloat software, from lessloc's [pattern catalog](https://lessloc.org/patterns/index.md). lessloc catches it as [`made-up-api`](https://lessloc.org/guide/reference.md#tier-1).

## What makes another language's API a bad practice?

The standard that calls it a bad practice: Sonar's quality profile for agent-written code targets "hallucinated APIs"; a call that does not exist fails the first time it runs.

## What does lessloc do about another language's API?

lessloc catches it as [`made-up-api`](https://lessloc.org/guide/reference.md#tier-1).

- `made-up-api` (tier 1): Another language's API, such as `null` in Python, `len()` in JavaScript or `None` in Go, or an import that no manifest declares and the platform does not provide.

## Examples

Caught as `made-up-api`:

```python [cp.py]
def first(xs):
    if len(xs) === 0:
        return null
    return xs[0]
```

Written well:

```python [cp.py]
def first(xs):
    return xs[0] if xs else None
```

Caught as `made-up-api`:

```python [tests/test_cr.py]
def test_load():
    doc = load("[a]\nb = 1\n")
    assert doc["a"] != null
```

Written well:

```python [tests/test_cr.py]
def test_load():
    doc = load("""\
[a]
smooth = true
""")
    assert doc["a"]["smooth"] is True
```

Caught as `made-up-api`:

```js [cq.js]
export const clean = s => s.strip();
```

Written well:

```js [cq.js]
export const clean = s => s.trim();
```

## Related patterns

The other patterns in [Calls and packages that do not exist](https://lessloc.org/patterns/index.md#calls-and-packages-that-do-not-exist):

- [Imports of packages no manifest declares](https://lessloc.org/patterns/undeclared-import.md): lessloc catches it as `made-up-api`: checked against every package.json, Python manifest, the standard library and the project's own modules.
