I have decided to use julia for a small script, that changes string ip4 address to integer ip4 address in a .csv
with ~20e+6 rows. I have to say the syntax for function chaining is pretty bad. You can’t even put |>
at the beginning of line!
function ip4ToNumber(string)
hexa = split(string, ".") |>
x -> parse.(x) |>
x -> hex.(x, 2) |>
x -> join(x, "")
parse(Int, hexa, 16)
end
It seems like julia tries to take little bit subject last approach (e.g. map
takes verb (function) as first argument and subject (data) as last argument) but falls back to subject first most of the time (see join
, hex
).
Now - parse
really creeps me out, since it puts subject at the end, but because it has optional argument, the subject ends up in the middle!
It would be so much better, if julia just picked one approach and followed it:
- subject last & currying - functional languages primarily use it
ip4ToNumber string =
hexa = split "." string
|> map parse
|> map (hex 2)
|> join ""
parse Int 16 hexa
- subject first & dot notation - OOP languages primarily use it
ip4ToNumber(string) {
hexa = string
.split(".")
.parse.()
.hex.(2)
.join("")
hexa.parse(Int, 16)
}
Not following convention is one thing, but complete lack of it is whole new level.