# Julia significantly slower than Matlab for simple sin(x) loop – am I doing something wrong?

**URL:** <https://discourse.julialang.org/t/julia-significantly-slower-than-matlab-for-simple-sin-x-loop-am-i-doing-something-wrong/133317>\
**Category:** New to Julia\
**Tags:** question, performance\
**Created:** [October 20, 2025, 10:02pm UTC](https://discourse.julialang.org/t/julia-significantly-slower-than-matlab-for-simple-sin-x-loop-am-i-doing-something-wrong/133317 "2025-10-20T22:02:41Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [October 21, 2025, 2:07pm UTC](https://discourse.julialang.org/t/julia-significantly-slower-than-matlab-for-simple-sin-x-loop-am-i-doing-something-wrong/133317/7 "2025-10-21T14:07:10Z")

</div>

> [@DNF](#):
>
> Also keep in mind that when you call code like this in Matlab, it is directly running a highly optimized C or Fortran implementation, possibly multithreaded. So it’s not Julia vs Matlab, but Julia vs C/Fortran. You should not normally expect Julia to outperform Matlab in those cases.

As I wrote in another thread, comparing to optimized library routines (like a vectorized `sin(array)` call) is not particularly interesting except to verify that Julia can produce good compiled code. Where you hope to get significant performance improvements is in cases where you have to write _new_ performance-critical code, not simply call one or two library functions.

> [@Julia's applicable context is getting narrower over time?](https://discourse.julialang.org/t/julias-applicable-context-is-getting-narrower-over-time/55042/40):
>
> If all the high-performance code you will ever need has already been written, then you don’t have as much need for a new language. Julia is attractive for people who need to write **new** high-performance code to solve **new** problems, which don’t fit neatly into the boxes provided by existing numpy [or Matlab] library functions.
> 
> It’s not that Julia has some secret sauce that allows it to beat C — it is just that its compiled performance is comparable to that of C (boiling down to the same LLVM backend), so depending on the programmer’s cleverness and time it will sometimes beat C libraries and sometimes not.

---

_[View the full topic](https://discourse.julialang.org/t/julia-significantly-slower-than-matlab-for-simple-sin-x-loop-am-i-doing-something-wrong/133317)._
