News for hackers. Stuff that matters.
Re:Julia 0.5 Highlights by jamii on Tuesday October 11, 2016 @02:28PM (#12687154)
Julia is very strongly typed, much more so than most dynamic languages. Because the type inference can remove type checks in performance-sensitive code, the language and standard library are much more willing to throw type checks around all over the place, which means that errors get caught much closer to where they were caused compared to most dynamic languages.

    julia> xs = ["foo", "bar"]
    2-element Array{String,1}:
     "foo"
     "bar"

    julia> push!(xs, 42)
    ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type String
    This may have arisen from a call to the constructor String(...),
    since type constructors fall back to convert methods.
     in push!(::Array{String,1}, ::Int64) at ./array.jl:479
    
    julia> xs = Any["foo", "bar"]
    2-element Array{Any,1}:
     "foo"
     "bar"

    julia> push!(xs, 42)
    3-element Array{Any,1}:
       "foo"
       "bar"
     42 
If what you are looking for is a statically typed language, then Rust has a very similar approach to data, types and polymorphism but with much more emphasis on catching errors at compile-time, at the cost of poor interactive development.

There are no comments on this comment yet.