Hi there!
I had included some Julia code in a benchmark I’ve run to see how it performs compared to a few other languages. Given what other people say, Julia should be very fast, but the program I wrote is much slower than e.g. Rust, Java and Lisp, so I supposed I’ve made a big mistake somewhere .
The program is a port of the Common Lisp version which you can find here.
My Julia port is here.
Notice this is my first ever Julia code! So I am sure I made lots of mistakes. But I would very grateful if anyone could show me what can be improved in order to make the code run as fast or faster than other programming languages.
I tried a few optimisations like replacing the arrays in charToDigit
with tuples but that didn’t help much.
If you’re curious, this problem has been the subject of two blog posts I wrote (links in the README on GitHub as I can’t post more links here it seems):
-
Revisiting Prechelt’s paper and follow-ups comparing Java, Lisp, C/C++ and scripting languages
-
How to write really slow Rust code
I only briefly mention Julia in those because I didn’t have time to verify and optimise the code yet, hence why I am here now. It would be fun to write a new blog post “showing how to write slow Julia code” similar to the Rust one, where the improvements to my initial version of the Julia code can be explained, and hopefully Julia programmers can benefit from learning where they need to be careful regarding performance. As in the Rust post, I obviously will give full credits to anyone helping!
Thanks for any assistance!
EDIT: a few contraints of the problem for those who don’t have time to read the full requirements:
- input phone numbers are encoded in ASCII but may contain non-digits that can be discarded.
- dictionary words also are encoded in ASCII and again, may contain non-alphabetic chars that can be discarded.
- both numbers and words MUST be printed as they are in the original files (cannot discard non-valid chars when printing them).
- maximum phone number lenght is 50 (don’t replace BigInt with Int64 for example, it won’t fit).
- sysout can be buffered but the program must print all solutions.
Please ask if anything else is unclear.