Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Raw speed. Although julia has several nice features (multiple dynamic dispatch, macros), the raw speed obtained by annotating code with types is mind blowing. You can for the most part write like python, then annotate the slowest parts with types. It works really well.


You don't even need to annotate things with types!

    > square(x) = x * x

    > @code_typed square(2.0)
    CodeInfo(
    1 1 ─ %1 = Base.mul_float(%%x, %%x)::Float64
    └──        return %1
    ) => Float64

    > @code_typed square(2)
    CodeInfo(
    1 1 ─ %1 = Base.mul_int(%%x, %%x)::Int64
    └──        return %1
    ) => Int64
Functions specialize automatically to the arguments you pass in.


Or, to see what's really going on at a low level you have immediate access to the native assembly from the REPL:

    julia> square(x) = x^2 
    square (generic function with 1 method) 
 
    julia> @code_native square(1) 
        .text 
    Filename: REPL[3] 
        pushq       %rbp 
        movq        %rsp, %rbp 
    Source line: 1 
        imulq       %rdi, %rdi 
        movq        %rdi, %rax 
        popq        %rbp 
        retq 
 
    julia> @code_native square(1.0) 
        .text 
    Filename: REPL[3] 
        pushq       %rbp 
        movq        %rsp, %rbp 
    Source line: 1 
        mulsd       %xmm0, %xmm0 
        popq        %rbp 
        retq


You don't need to annotate function definitions with types, but you should actually annotate your composite type definitions with concrete (parametric) types for each field.


Syntax, semantics (multiple dispatch, type system), and community (so many clever people working together sharing expertise)


You don't need to annotate types to get the speed.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: