Hacker News new | ask | show | jobs
by singularity2001 907 days ago
are my main concerns resolved:

• Hello World 200 MB ?

• discoverability of functions:

    object.fun<tab> => fun(object) in REPL / IDE?
object.<tab> => List of applicable functions?
3 comments

How about a 16K Hello World?

  julia> using StaticTools, StaticCompiler
  
  julia> hello_world() = printf(c"Hello World\n")
  hello_world (generic function with 1 method)
  
  julia> compile_executable(hello_world, (), "./")
  "~/hello_world"
  
  shell> ./hello_world
  Hello World
  
  shell> du -h hello_world
  16K hello_world
See https://github.com/brenhinkeller/StaticTools.jl for further details and limitations.

For discovering methods you can do

  julia> ?("hello", 1, 2.0)[TAB]
  broadcast(f, x::Number...) @ Base.Broadcast broadcast.jl:844
  readuntil(filename::AbstractString, args...; kw...) @ Base io.jl:520
  ...
See the Tab Completion section of the REPL documentation, https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion .
> discoverability of functions

I think for the most part this is solved. It works very well and has good integration with VS Code:

    julia> integrator.<tab>
    EEst                    accept_step             alg                     cache                   
    callback_cache          differential_vars       do_error_check          dt                      dtacc ...
etc. cut short.

    julia> ODEProblem(<tab>
    ODEProblem(f::SciMLBase.AbstractODEFunction, u0, tspan, args...; kwargs...) @ SciMLBase C:\Users\accou\.julia\dev\SciMLBase\src\problems\ode_problems.jl:183
    ODEProblem(sys::ModelingToolkit.AbstractODESystem, args...; kwargs...) @ ModelingToolkit C:\Users\accou\.julia\packages\ModelingToolkit\arrCl\src\systems\diffeqs\abstractodesystem.jl:911
    ODEProblem(f, u0, tspan; ...) @ SciMLBase C:\Users\accou\.julia\dev\SciMLBase\src\problems\ode_problems.jl:187
    ODEProblem(f, u0, tspan, p; kwargs...) @ SciMLBase C:\Users\accou\.julia\dev\SciMLBase\src\problems\ode_problems.jl:187

> Hello World 200 MB

Not quite. There's a bunch of knobs you can use to get small binaries (I use this for industrial deployments often), but Jeff Bezanson gave a really nice talk at JuliaCon Local Eindhoven 2023 that described the reasons for the large binaries, what the memory is actually attributed to, and what to do about it (https://youtu.be/kNslvU3WD4M?si=hwo9AgXthNpiQ3-P). With the "normal options" you get to about 15MB now, still bad but not half as bad. The vast majority of that is the base system image. Jeff's talk then goes into the next steps with reducing the size of that base system image.

not solved:

julia> x="hi" "hi"

julia> x.<tab>

nothing!

   julia> propertynames(x)
   ()
Nothing is the correct answer there because there are no properties. `x.y` for any y is an error, so that is correct.

If what you're trying to do is instead discover functions which are compatible with a given signature, you can use what is described in the other post:

    julia> ?("hello", 1, 2.0)[TAB]
    broadcast(f, x::Number...) @ Base.Broadcast broadcast.jl:844
    readuntil(filename::AbstractString, args...; kw...) @ Base io.jl:520
    ...
  
which shows all of the dispatches that match an argument set and thus the functions that can be called on it. Generally the IDE completions do a bit nicer display of that then the REPL though.