Coding in Julia again

I’ve noticed is start up time still can be very long. I think it’s called time to plot. I forgot many Juliaisms. I already mentioned strings verses characters. Another gotcha…string concatenation which uses the ‘*’ and not the more common ‘+’. I think the rest of this paragraph is wrong and applies to Python. Yesterday I ran across one that use to work but evidently now works differently…repeating strings or characters. You use to use ‘*’. So if you wanted a strong of 20 Xs you would code ‘X’ * 20. But now you use the caret ‘^; symbol so it’s now ‘X’ ^ 20.

I personally have never worked with a language that would break so often between minor point releases. Currently the version I use is at 1.6.3. Python broke between version 2 and 3. But that was expected, it was discussed long beforehand and was a major point release. That’s why I got excited when Julia version 1 came out. I think of version 1 as…ok this is now ready for production work.

Still I like Julia. It’s very Python like. Except for me a few big improvements over Python. I know many if not most people will disagree. But I really like one based arrays which most languages don’t use. Silly me for associating one with the first. So for example if there was a table with 2 piles of objects, diamonds and behind it rocks. And I had a choice of picking one. I should say I’ll take the first pile. And was handed the rocks, I’d be pretty upset! Well you chose the first pile and should have chosen the zeroth pile silly. Another thing I like over Python and is probably related is Julia’s slicing.

Here is another example Julia error message confusion. I went through this before. I guess it’s just something I have to get use to again. Below is the error message that mentions lines 560, 87, 145, 91 and 65.

bill@bill-MS-7B79:~/MyStuff/Julia$ julia findMissing.jl
Home :/home/bill
533
Start
ERROR: LoadError: MethodError: no method matching +(::String, ::Int64)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any…) at operators.jl:560
+(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:87
+(::LinearAlgebra.UniformScaling, ::Number) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/uniformscaling.jl:145

Stacktrace:
[1] top-level scope
@ ~/MyStuff/Julia/findMissing.jl:91
in expression starting at /home/bill/MyStuff/Julia/findMissing.jl:65
bill@bill-MS-7B79:~/MyStuff/Julia$

My code seen below shows lines 65-108. So only lines 65, 87 and 91 apply. Line number 91 is in fact the culprit. It should look like line 90 instead.

BTW I wrote a quick Julia program to show the below line numbers. I thought that would be something common. Atom and VS Code had extensions like “Copy With Line Numbers”. However the link for Atom was bad and VS Code didn’t work even though it said “Copied!”. What ever was last in the clipboard was pasted with no line numbers.

65 for f in files
66     global start, lstMn, lstYr, lstDat
67     yr=f[1:4]
68     # println(yr)
69     mn=f[5:6]
70     mn=lpad(mn,2,"0")
71     thisDat=yr*mn
72     # println("td",thisDat)
73     # println(yr,mn)
74     if start
75         println("Start")
76         lstYr="1965"
77         # println(typeof(lstYr))
78         # println("lstYr")
79         lstMn="05"
80         lstDat=""
81         # println(typeof(lstMn))
82         start=false
83         # exit()
84     end # this if
85     if thisDat==lstDat
86         continue
87     end
88     lstDat=thisDat
89     if yr!=lstYr
90         # nxtYr=parse(Int,lstYr)+1
91         nxtYr=lstYr+1
92         if yr!=string(nxtYr)
93             println(lstYr+1," Missing")
94         end # this if
95     end # outer if
96     nxtMn=parse(Int,lstMn)+1
97     if nxtMn>12
98         nxtMn=1
99     end
100     thisMn=parse(Int,mn)
101     # println(yr," ",lstYr)
102     if thisMn!=nxtMn
103         println(lstYr, lpad(string(nxtMn),2,"0")," <"^15," Missing")
104     end
105     println(f)
106     lstMn=mn
107     lstYr=yr
108 end  # for