# Is there a strong case that Julia is a more composable language?

**URL:** <https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554>\
**Category:** General Usage\
**Tags:** question, python\
**Created:** [August 24, 2024, 10:26am UTC](https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554 "2024-08-24T10:26:33Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Satvik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/satvik/32/20486_2.png) [@Satvik](https://discourse.julialang.org/u/Satvik)\
**Post date:** [August 24, 2024, 5:16pm UTC](https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554/6 "2024-08-24T17:16:49Z")

</div>

Another big reason is that almost everything in Julia is built around the native `Array` type. In Python all the big ecosystems use their own, incompatible version of arrays, with duplicate versions of methods like `.std()`

For example, you might think you could write a function like

```julia
def sharpe(s):
	return s.mean()/s.std()

```

in Python and have it work the same on pandas series, numpy ndarrays, and pytorch tensors. But you can’t, because numpy uses 0 degrees of freedom by default, while the others use 0, so you’ll get different results.

What if you try to explicitly pass degrees of freedom, like

```julia
def sharpe(s):
	return s.mean()/s.std(ddof=1)

```

Now this works for pandas and numpy, but fails for pytorch, because it expects an `unbiased` argument instead of `ddof`. In order to actually get a version that does the same thing with each type of array, you need to write something like

```julia
def standardized_std(data, ddof):
	if isinstance(data, torch.Tensor):
		return data.std(unbiased == 1)
	else:
		return data.std(ddof=ddof)

```

Which is pretty clunky!

Meanwhile in Julia, almost every implementation of `std` you’ll see just looks at an underlying array and calls `std` from `Statistics`, giving you the same functionality and interface by default.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554)._
