*Note: If you don't care to see updates about programming/Julia, you can navigate to my profile page (by clicking on my picture), then click on "Collections" and then click "Following" on the "Julia Programming Tips" collection to not see these posts.
As a package maintainer, how do I maintain a single code source instead of branching different versions (say for version 0.3 vs. 0.4)?
This is a great question with a relatively new answer. Originally there was the `VERSION` variable defined in Base that allowed one to put something like:
if VERSION > v"0.4.0"
# version 0.4 code
# version 0.3 code
While this works, it's a little clunky because often times the new feature/syntax you want to use was introduced at a specific commit, so just specifying `v"0.4.0"` means anyone on 0.4, but that doesn't yet have the new commit will see errors. It then becomes a hassle to track down the exact commit relative to 0.4 to version off of (e.g. `v"0.4.0-dev+4928"`). What's worse is that new syntax may not even be parseable in the new commit.
Enter Compat.jl (https://github.com/JuliaLang/Compat.jl). Compat.jl is a package that maintains compatibility changes between versions in Julia. It's a central repository for all packages to use to simplify the versioning process and provide an easy way to use new features/syntax in packages, while easily maintaining backwards compatibility. Like the new Dict syntax in 0.4? Try this:
new_fancy_dict_of_lies =@compat Dict("money" => "happiness")
Boom! Code automatically compatible between versions of Julia. Super simple stuff.
Anyway, that's it for today's Julia tip, feel free to ask any questions, suggest future tip topics, or, shudder, correct my code :( Have a swell day!
Also check out a nifty IJulia notebook that was put together to highlight some of the happenings in the 0.2 community: https://groups.google.com/d/topic/julia-dev/WvdgjER4zBM/discussion
A big congrats/thanks to all who have contributed to 0.2 and here's to 0.3!
How do I easily make my code portable cross-platform?
As much as a core language library tries to abstract away various platform differences (Windows, OSX, Linux, etc.), there are certain pieces of functionality that still persist where there are differences between platforms. This is a common problem when developing packages that use 3rd-party binaries (C or C++ shared libraries). Base Julia provides a few ways to easily make your code cross-platform.
Julia provides a few macros for convenience for dealing with cross-platform code:
@windows_only really_cool_function(#= windows-specific code =#)
@osx_only really_cool_function(#= OSX-specific code =#)
@linux_only really_cool_function(#= linux-specific code =#)
Here, I'm defining a single `really_cool_function`, yet the implementation will be different depending on what platform the code is run on. This is wonderful for users of this code because they themselves don't have to put in any `@windows_only/@osx_only`, they just call `really_cool_function` and it "Just Works (TM)".
There is also a ternary operator form like
t =@osx? "yes, I'm a mac" : "No, I'm not a mac"
Some don't like this form because it's "too cute" or a pun on the ternary operator, but it exists nonetheless.
Enjoy making your code cross-platform!
- I'm fanatical about ultimate frisbee; I don't quite understand my obsession, but that I'm mesmerized by a flying disc
- My favorite desserts would have to be banana cream pie (don't forget the cream!) and anything funfetti....seriously
- Grew up on old-school musicals, especially the cheesy ones
- I hate the alphabet and struggle to remember the order of letters
- Sports: College > Pros
- If I were ridiculously rich and was given one way to completely waste some of my money it would be in wearing a brand new pair of socks everyday.....love new socks.
- The thing I hate more than anything in this world is styrofoam. Friends will throw it on me occasionally just to watch me squirm
- and I'm a mormon (cue cheesy commercial...)
- Carnegie Mellon UniversityMISM BIDA, 2013 - present* Currently enrolled in Computational Methods for the Smart Grid (http://www.cs.cmu.edu/~zkolter/course/15-884/index.html), an applied machine learning course covering optimization techniques in power systems using publicly available supply/demand data for the electric grid in Pennsylvania (PhD level course) * The Business Intelligence and Data Analytics concentration involves additional data-intensive courses in advanced statistics, data mining, warehousing, hadoop, social media analytics, and a captstone project working with a real company on an analytics solution * Additional elective courses will cover advanced machine learning techniques, convex optimization, and predictive modelling
- Brigham Young UniversityBusiness Strategy and Economics, 2011
- Rigby High School
Netflix Prize: Forum / Grand Prize awarded to team BellKor’s Pragmatic C...
It is our great honor to announce the $1M Grand Prize winner of the Netflix Prize contest as team BellKor's Pragmatic Chaos for their verifi
Papers The Data Linkage Project Publication 2010 HARRA: Fast ...
Publication. 2010. HARRA: Fast Iterative Hashed Record Linkage for Large-Scale Data Collections, Hung-sik Kim, Dongwon Lee, In 13th Int'l Co