---
title: "Mark Kittisopikul (@markkitt) | Hashnode"
description: "Scientific Software Engineer. Read the latest articles by Mark Kittisopikul on Hashnode."
url: "https://hashnode.com/@markkitt"
---

@markkitt

# Mark Kittisopikul

@markkitt · Joined June 2023

Scientific Software Engineer

## Comments

[Value based dispatch with a string presents some challenges. If you use a Symbol, an interned string, directly, then value based dispatch can be made very efficient due to constant propagation. julia> @btime ValueFruitFactory.fruit(:orange) 1.424 ns (0 allocations: 0 bytes) Main.ValueFruitFactory.Orange() julia> f() = ValueFruitFactory.fruit(:orange) f (generic function with 1 method) julia> @btime f() 1.423 ns (0 allocations: 0 bytes) Main.ValueFruitFactory.Orange() julia> @code\_typed f() CodeInfo( 1 ─ return $(QuoteNode(Main.ValueFruitFactory.Orange())) ) => Main.ValueFruitFactory.Orange Compare the typed code with the string version. julia> @code\_typed g() CodeInfo( 1 ─ %1 = $(Expr(:foreigncall, :(:jl\_string\_ptr), Ptr{UInt8}, svec(Any), 0, :(:ccall), "orange"))::Ptr{UInt8} │ %2 = Core.sizeof("orange")::Int64 │ %3 = $(Expr(:foreigncall, :(:jl\_symbol\_n), Ref{Symbol}, svec(Ptr{UInt8}, Int64), 0, :(:ccall), :(%1), :(%2), "orange"))::Symbol │ %4 = invoke Main.ValueFruitFactory.fruit(%3::Symbol)::Union{Main.ValueFruitFactory.Apple, Main.ValueFruitFactory.Orange} └── return %4 ) => Union{Main.ValueFruitFactory.Apple, Main.ValueFruitFactory.Orange}](https://hashnode.com/posts/fruity-composable-design-patterns-in-julia/64958d80d5dec1509f8f963c/comment/6498cd575244606d9b5fd35f)

Comment · Article · Jun 25, 2023 · [Fruity Composable Design Patterns in Julia](https://hashnode.com/posts/fruity-composable-design-patterns-in-julia/64958d80d5dec1509f8f963c)
