# Julia's array processing vs J

**URL:** <https://discourse.julialang.org/t/julias-array-processing-vs-j/106600>\
**Category:** Offtopic\
**Created:** [November 22, 2023, 9:49pm UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600 "2023-11-22T21:49:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neophytedave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neophytedave/32/202273_2.png) [@neophytedave](https://discourse.julialang.org/u/neophytedave)\
**Post date:** [November 22, 2023, 9:49pm UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/1 "2023-11-22T21:49:03Z")

</div>

Whenever I read a laudatory comment re: Julia’s performance, I am frequently brought back to J’s performance claims, e.g. [Vocabulary/ArrayProcessing - J Wiki (jsoftware.com)](https://code.jsoftware.com/wiki/Vocabulary/ArrayProcessing)  
Does anyone in this forum know of/use J, APL’S successor, or any of APL’s modern incarnations? Any comments J’s array processing vs Julia’s?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 22, 2023, 11:06pm UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/2 "2023-11-22T23:06:23Z")

</div>

This is hard to answer in general. As far as I can tell, J is interpreted. Julia is compiled. Consequently, J will be quick to respond if you are using its built in compiled routines. In Julia, we generate machine code so I would expect to encounter some compiler latency. However, the resulting machine code would be expected to be faster and more efficient than an interpreter.

---

<div class="post-metadata">

**Author:** ![neophytedave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neophytedave/32/202273_2.png) [@neophytedave](https://discourse.julialang.org/u/neophytedave)\
**Post date:** [November 22, 2023, 11:40pm UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/4 "2023-11-22T23:40:46Z")

</div>

Of course I would want any performance comparison between the two done post-compilation in Julia. My sense reading J docs is that J is more array savvy than Julia, and knows (for example) how to deal correctly with numeric amounts, without the user having to interrogate such things. According to those docs, J knows how to scale (up) without necessitating that the user dig into any of J’s innards, as a Julia user/programmer might need to. As a simple example, when working in Julia and working with something as simple as a scalar, do I not have to know whether a number is an int, int32, int64, float32/64, and program accordingly? With J I do not have to know that.

---

<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:** [November 23, 2023, 12:11am UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/5 "2023-11-23T00:11:30Z")

</div>

> [@neophytedave](#):
>
> As a simple example, when working in Julia and working with something as simple as a scalar, do I not have to know whether a number is an int, int32, int64, float32/64, and program accordingly? With J I do not have to know that.

I’m not sure what you mean—you can write generic code in Julia that works with any numeric type (without sacrificing performance). Being able to write type-generic code is a fundamental goal of most high-level languages these days.

I’ve never programmed in J, but the examples I’ve seen on places like Rosetta Code amaze me at how concise it can be (albeit quite difficult to read for outsiders). Seems like a fun language, if a bit esoteric.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 23, 2023, 12:15am UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/6 "2023-11-23T00:15:35Z")

</div>

> [@neophytedave](#):
>
> My sense reading J docs is that J is more array savvy than Julia, and knows (for example) how to deal correctly with numeric amounts, without the user having to interrogate such things. According to those docs, J knows how to scale (up) without necessitating that the user dig into any of J’s innards, as a Julia user/programmer might need to. As a simple example, when working in Julia and working with something as simple as a scalar, do I not have to know whether a number is an int, int32, int64, float32/64, and program accordingly?

Julia has a pretty comprehensive type conversion and promotion system. You often do not need to think explicitly about types.

```julia-repl
julia> f(a, b) = 2a + b^2                                         
f (generic function with 1 method)                                                                                                  

julia> f(2,5)                                                     
29 
                                                                                                                                 
julia> f(2,5.5)                                                   
34.25   
                                                                                                                            
julia> f(2.45,5.5)                                                
35.15  
                                                                                                                             
julia> f(π, 0)                                                    
6.283185307179586
                                                                                                                   
julia> f(3//10, 2//10)                                            
16//25

```

See [Conversion and Promotion · The Julia Language](https://docs.julialang.org/en/v1/manual/conversion-and-promotion/#Promotion)

Yet, Julia does type values.

```julia-repl
julia> @code_typed f(2,5.5)                   
CodeInfo(                                     
1 ─ %1 = Base.mul_int(2, a)::Int64            
│ %2 = Base.mul_float(b, b)::Float64        
│ %3 = Base.sitofp(Float64, %1)::Float64    
│ %4 = Base.add_float(%3, %2)::Float64      
└── return %4                            
) => Float64

```

The implicit typing helps compile the code. Here is the underlying LLVM IR which is then translated into your processor’s machine code.

```julia-repl
julia> @code_llvm debuginfo=:none f(π, 0)     
define double @julia_f_430(i64 signext %0) #0 {                                             
top:                                            
%1 = mul i64 %0, %0                           
%2 = sitofp i64 %1 to double                  
%3 = fadd double %2, 0x401921FB54442D18      
 ret double %3                               
}

```

---

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [November 23, 2023, 12:37pm UTC](https://discourse.julialang.org/t/julias-array-processing-vs-j/106600/7 "2023-11-23T12:37:54Z")

</div>

I had used kx’s kdb+ for nearly 10 years. Its power is its terse and domain specific set of operations that are highly optimized for working with financial market data.

If you’re just performing relatively simple operations on arrays, particularly time-series joins, you won’t find anything more productive than what can be written in 1 line of q/k.

The performance of vectorized operations is well optimized and on par with Julia, but once things get more complex and path-dependent, the overhead of an interpreted language and lack of flexible data-types become more troublesome.
