Starting guide for Julia, coming from e.g. Python or C++

AI answers are often unbelievably good, and I believe also for this topic: ChatGPT - Julia Dict Comparisons

21. A particularly important Python → Julia mapping

I’m not new to Julia actually, I just though there should be a list of recommend packages coming from e.g. Python, and I recommend using OrderedCollections, Revise as a starting point, the latter just during development.

Python’s standard library is incredibly broad, you can e.g. send email with the standard library. Consider using PythonCall to get access to all of it, to use it as such as a “tool”. I’m most interested in A. more core capability/data structures, and to some degree about B. tools people know of in e.g. Python, and want a similar native Julia package for. Feel free to list a minimal list of packages for A (and/or B), even for C. for (web) frameworks for Julia parity. For those who know, or for new users who do not know the mapping, so we can help. The manual has a section for difference with many languages vs. Python, C++ etc. It and the help might need amending:

help?> Dict
..
  Dict{K,V}() constructs a hash table with keys of type K and values of type V. Keys are compared with isequal and hashed with hash.

The example is only implicit about unordered, so I suggest changing to:

  Dict{K,V}() constructs a (unordered) hash table with keys of type K and values of type V. Consider `using OrderedCollections` for access to `OrderedDict`. Keys are compared with isequal and hashed with hash.

To partially answer my own question, there is e.g. SMTPClient.jl to send email, no need for PythonCall.jl there (for basic capability, i.e. the actual sending). You can use all of Python’s current email capability, including email to construct the email, before sending; note smtpd was removed in Python 3.12, with aiosmtpd a substitute, and my answer doesn’t cover it or such servers.

I’ll just post this too even though AI generated (at least good for discussion if anything wrong there):

1. The genuinely important Python stdlib gaps

I’d put these near the top.

Python Julia stdlib/Base My assessment
heapq DataStructures.Heap Missing from stdlib, but trivial package substitute
collections.deque DataStructures.Deque Same
collections.defaultdict get! / custom types DataStructures.DefaultDict [Here AI was wrong: “No exact equivalent”]
collections.Counter StatsBase.countmap etc. Package
enum @enum Julia actually has it
dataclasses structs Julia doesn’t need the mechanism
functools do blocks, closures, higher-order functions Mostly unnecessary
itertools Base.Iterators Julia is arguably better here
operator operators/functions directly Mostly unnecessary
weakref WeakRef Julia has it
copy copy, deepcopy yes
pickle Serialization yes, though not equivalent in purpose/portability
json JSON package not stdlib
re Regex yes
argparse ArgTools.jl / packages not a real equivalent
subprocess Cmd, run, pipelines yes
pathlib Base.Filesystem yes, although less elegant
tempfile mktemp, mktempdir yes
shutil filesystem functions mostly yes
logging Logging yes
warnings Logging / warnings machinery not quite equivalent
traceback stacktrace machinery yes
inspect reflection Julia has a different, often more powerful model
ast Meta, JuliaSyntax yes, but fundamentally different
dis code_*, @code_* yes, arguably much richer
threading Base.Threads yes
multiprocessing distributed processes yes
asyncio Tasks/Channels yes, but different model
socket Base.Sockets yes
ssl MbedTLS [or rather OpenSSL.jl?] stdlib package
http.client / urllib Downloads yes
email ??? real gap
smtplib [SMTPClient.jl] real-ish gap
imaplib ??? gap
ftplib ??? gap
zipfile Tar etc. ZIP is surprisingly awkward
gzip CodecZlib.jl package
bz2 CodecBzip2.jl package
lzma CodecXz.jl package
sqlite3 SQLite.jl package
dbm [SQLite.jl] gap
configparser [avoid .ini files, rather use TOML or PythonCall.jl] gap
tomllib TOML yes
csv CSV.jl package
xml XML packages package
html.parser Gumbo etc. package
zipapp [AppBundler.jl or JuliaC.jl] gap
venv Pkg environments Julia arguably better
venv + pip Pkg major Julia advantage

zipapp is a rather unusual “library”/concept, and not a substitute to simply call it with PythonCall.jl, I replaced its ??? (and edited more such) with plausible alternatives. dbm is likely a real gap, but who cares… I put in indirect substitute…

I’m starting this exact thing for RepliBuild.jl to wrap Python. Python will get a direct type mapping like C/C++ but I’m going to incorporate the GIL aspects too, and start wrapping all the important Python libraries.

You put some great targets up though lol :laughing: I haven’t even looked at what’s missing or the hardest, yet just that Python compiles with clang and has DWARF…

Palli wants me to spell better.