
Some fun with π in Julia - one-more-minute
http://julialang.org/blog/2017/03/piday
======
Tarrosion
Most times a julialang.org blog post is posted to HN, I wonder whether the
choice of content is well chosen to spread awareness of and interest in Julia.

I write this as a huge Julia fan; I use Julia daily, and it is both my
favorite language and the language I know best. So I already think Julia is
great. But reading many Julia blogs, especially those from julialang.org,
would make me think Julia is only useful for very narrow scientific
applications if I didn't already know better.

I like Julia because it's extremely fast and extremely expressive - and I
don't just mean "expressive" as in "can be written like a dynamic/scripting
language," though it can. I mostly mean that the combination of its type
system and multiple dispatch allows some really elegant abstractions.

~~~
tnecniv
What's your working setup with Julia? I'm looking at switching over from
MATLAB as soon as the semester is over.

~~~
Tarrosion
My setup is dead simple. I'm on Windows, so I use Notepad++ with syntax
highlighting as my editor and do a lot via the REPL. I just use regular Julia,
not JuliaPro. Installing packages hasn't been a problem for me, just
Pkg.add("PackageYouNeed"). I've had very few problems with package setup in
the past and none recently.

On a 4-core CPU I have the environment variable JULIA_NUM_THREADS set to 3 so
that when Julia is doing threaded worked there's still a core free for web
browsing.

One potential gotcha: the Julia docs will mention that you can access shell
commands from the REPL by starting your line with a semicolon, e.g. ;ls. For
me this only works if you start Julia from something like Git Bash, not cmd.

Lots of people seem to like Juno (junolab.org) as an IDE. The team behind it
has made incredible progress recently, and sometimes I use it for its GUI
around the debugger, but for the most part I tend to stick to Notepad++.

------
zengid
So, sorry to change the subject away from pi, but how does Julia do on the
code-gen end? Are we talking SIMD type optimizations? Are there hooks in the
language for tuning hot-code?

I'm curious because I'm trying to find an example of a "non-scalar"
programming language, a la this attempt here[1].

Thanks for the help!

[1][https://news.ycombinator.com/item?id=13867574](https://news.ycombinator.com/item?id=13867574)

~~~
kristofferc
Julia uses LLVM to do code-gen so whatever optimizations are available in LLVM
are available to Julia. If the auto-vectorizer in LLVM is not kicking in, it
is possible to write explicit SIMD with the
[https://github.com/eschnett/SIMD.jl](https://github.com/eschnett/SIMD.jl)
package.

------
mastax
I have always been skeptical about 'scientific' languages. Why do you need a
special language when any general language + some libraries will do? This is a
good example of a feature that only really makes sense in a scientific
language.

~~~
nerdponx
In R, I can import a CSV, plot a histogram of each column, and fit a linear
regression of one column against the others in about 5 minutes and 15 lines of
code.

In Python, I can do the same thing if I install the Pandas and Statsmodels
libraries first.

Try that in Ruby, Perl, C++, C, Java, Rust, Haskell, Common Lisp, or just
about any language you can think of. Good luck.

~~~
goatlover
The other great thing about R is the amount of information it outputs when you
run a stats function.

~~~
nerdponx
It's easy to forget that R inhabits a gray area between a full-fledged
programming language and a "statistics package" like SAS or SPSS or Stata or
GRETL.

------
blt
Monte Carlo computation of pi would be a fun addition to this post...

~~~
simonbyrne
I actually had it in a rough draft, but didn't get it finished in time. Maybe
next year.

------
bo1024
This arbitrary-accuracy treatment of pi is cool, but I'd be curious to see an
application where greater precision of pi than a float64 is actually useful...

------
throwme_1980
Genuine question, As a professional developer, why would you restrict yourself
to such technology? what we should be asking here is why? give me one scenario
where this language is more appropriate than the plethora of other domain
specific languages. would you bet your company on such language when there is
more mature languages already ?

~~~
nerdponx
Are you asking "why do we use scientific languages"? If that's your question,
the answer is the same reason that you don't write a webserver in assembly.

If you're asking "why Julia versus other languages" it's that, well, Julia is
fighting to answer that question for itself. As far as I can tell:

\- Versus R and Octave: performance, coherent syntax, and more features for
writing "programs" instead of just "scripts" \- Versus Python + the Scipy
stack: its scientific features are built into the language (instead of being
an awkward layer on top of it) \- Versus any proprietary platform (SAS,
Matlab, etc): it's open source and free-as-in-beer, and therefore not confined
to legacy/enterprise applications

I'm a data scientist and I currently use R and Python. I've been wanting to
give Julia a try for months, and now that the ecosystem is starting to mature
(plotting and data frames are must-haves for me) it's making more sense to
spend some time with the language.

~~~
vanderZwan
Are you aware that can call R and Python from Julia with practically no
overhead? And I mean that both in performance and expressiveness?

~~~
nerdponx
I didn't know this. Will look into it, thanks!

edit: looked up "call R from Julia", it looks like there's a n "RJulia"
library for this. Assuming there's a Python equivalent? How does this compare
to, say, using RPy2 in Python (which is nice but kind of annoying)?

~~~
3JPLW
I think RJulia goes the other way; calling Julia from R.

You want RCall.jl and PyCall.jl. Both allow you to directly work with and
manipulate native objects. RCall even allows you to bring up an R REPL.

------
spraak
Julia all the things!

~~~
tempodox
I wish! It breaks my heart that this language doesn't produce standalone
binary executables.

~~~
stimj
There are ways: [http://stackoverflow.com/questions/36815324/produce-a-
standa...](http://stackoverflow.com/questions/36815324/produce-a-standalone-
executable-from-a-julia-script)

