Julia’s Strings Compared To Python’s Strings

I would much rather work on strings in Julia.

Emma Boudreau
chifi

--

julia and python

Julia and Python are interesting languages to compare and contrast, and both are impressive for their own reasons. Julia has the potential to be your Python replacement as well as your Python’s companion. Julia is a completely new language residing in a novel paradigm, whereas Python revolutionized the accessibility of software development. Both of the languages are incredibly different, but also feature numerous similarities.

Whereas Python has classes with attributes and member methods, Julia’s method system is instead based around the Function . Instead of member methods being part of a class, a Method becomes a Function name (you will see this in Julia as typeof(funcname)) and the arguments for that Method . This provides Julia with similar capabilities — inheritance of methods and the same function used for multiple types, but from a completely different approach — from the functions, rather than the types.

function example(x::String)
x * " $(x)"
end

function example(x::Int64)
x += 1
end

println(example("hello")) # args(::String) will go to method 1

println(example(5)) # args (::Int64) will go to method 2

hello hello
6
methods(example)

# 2 methods…

--

--

No responses yet