8 ms·
Some fun with π in Julia
- deleted 10y ago[deleted]
- spraak 10y agoJulia all the things!
- throwme_1980 10y agoGenuine 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 ?
- stimj 10y agoI think one of the strengths of this approach is easily implementing numerical methods/approaches from papers and having it just work. If you work in academia or in an R&D field, this is valuable. I don't think Julia is presently positioning itself to be the core language a company's product is based on.
- throwme_1980 10y agohaving it "just Work" is relative even in academia and R&D, again, there are domain specific languages being used in these environments that "just work" and have been designed to do so in the most efficient manner.
- goatlover 10y agoSo your question is applies to Python, Scala, Ruby or any other non-domain specific language, not just Julia.
- nerdponx 10y agoAre 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.
- tnecniv 10y agoIt's worth noting that MATLAB is a horrible language despite it's massive success. I feel like I'm baffled by something new in the design every day.
- pollitos 10y ago"Why do we use scientific languages?" is very true. Applause to the Julia contributors for their work on this innovative language with great out of the box support for modern computer chip architectures. However, they have fibbed to build up momentum, particularly their performance benchmarks. The tests are of compiled Julia with OpenBLAS for the benchmarks against out of the box versions of the other languages. Also, the benchmark code in other languages is with a style that is among the slowest implementations for each language. No seasoned programmer in any of those languages would write code in such a way. It does seem that there is co-ordination to get Julia posts most attention, timing and upvoting. Nonetheless, credit where it's due. It should become an awesome language, marketing hacks notwithstanding.
- ViralBShah 10y agoWe use whatever BLAS is linked to in a commonly available official distribution. Julia was one of the first to take this seriously and bundle a high performance BLAS as the default - and I think more projects are following our lead and doing the same. Also, only one benchmark actually uses BLAS. As for co-ordination on Julia posts - there is none. We submit all our blog posts to HN, and while some do reach the front page, many others do not. Glad you like Julia and hope this helps.
- make3 10y agoIt's much faster than Python, has optional typing (good thing), and will soon support real multi-threading (support is currently experimental). It can also import anything in Python in a breeze, if it needs to, but this is secondary imho. But still, as you see, there is a lot of upside.
- dhfhduk 10y agoI'm not sure about their implementation of pi in particular. To me it seems elegant, and as someone who has needed arbitrary precision arithmetic, I can see the appeal for how they are handling pi, and appreciate this attention to detail. As for your broader question, Julia definitely fills a gap that I have been pained by for years. I've used R since it was in beta, and it is slow, which is a pain when you are discussing numerical needs. Yes, you can program in something like C/C++, but that is painful because of its overhead and dependency complexity (although it's surprisingly become less painful over time). Python could be used too, and probably is better at this point in that regard, but it has many of the same problems as R. Julia is open-source, fast, and well-thought out with regard to modern numerical programming problems. I can write something in Julia and it performs essentially as well as something in C, which is a huge time saver in multiple respects. I do wish Julia were more general-purpose in its orientation, or that the solutions it offers were coming from a more general-purpose language, but at the moment that doesn't seem to be in the cards. Maybe as it grows it will find use as a more general-purpose language, which is possible; maybe as languages like Rust or Go grow they will occupy this niche as well. Rust is interesting to me in this way, but currently it has little to offer in terms of simplification over C++ for numerics, and Go is not friendly to numerics. I personally like Stanza, but it's in its infancy, and no one probably even knows what I'm talking about. For whatever reason, my experience has been that numerical programming has been a kind of isolate in programming. Numerical computing has always seemed slightly neglected in programming languages, and languages that have targeted numerical computing have often never been able to shake the "domain specific" label. I've just sort of come to see it as part of the territory. There's nothing wrong with Python, C, or R. Also, languages change rapidly, so who knows what will happen. At the moment, though, Julia offers the best of all three and the only big downside is lack of libraries, which is becoming less and less of an issue every day (I wouldn't say there's a lack of libraries, more that there's fewer libraries). So I think it's deserving of its current attention. I guess the question is, why would a systems programmer use C, or a web programmer use Javascript, or a network infrastructure programmer use Erlang, etc. etc. etc.?
- jernfrost 10y agoGenuine question, why do you assume it is a restriction? I am a professional developer and not a researcher or scientist which is the original target for Julia. Yet I find Julia to be my favorite language, and I've tried a lot of them. I can't think of any language which I find as expressive as Julia apart from Haskell, but that is exceedingly cumbersome to deal with given the strict type system. Haskell is beautiful but it is overly academic and requires a lot of investment in time and brainpower to work in your favor. Julia on the other hand is quite quick to learn and gets you productive quickly. I'll mention multiple areas I think Julia excels. If you want to write quickly high performance numerical software then I don't see what the alternatives are. It is the best language I've encountered for writing shell scripts. Bash is terrible due to the difficulty of factoring the code into functions and the frequency in which you forget to quote variables properly. Many end up thus using Python or Ruby. Ruby seems very popular, but Julia really works better. It has tighter integration with the shell and handles chaining, reading and writing to shell commands much nicer. It also has all sorts of useful stuff ready to use out of the box and sane function names etc. I find it much more cumbersome to write shell scripts with python. Awkward to call processes. Got to always remember what every little module you got to import. Because of multiple dispatch, Julia allows much better naming of functions. And as a computer language geek I love powerful LISP macros, but I can't get used to LISP syntax. Julia is the only language I know of which gives access to powerful macros and code generation similar to LISP.
- mastax 10y agoI 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.
- rrock 10y agoAs a scientist, it's nice to have an option where I can easily espress my problem, and get a speedy solution at the end. Julia hits this sweet spot. I translated some of my code from one of those general purpose languages to Julia 0.2, years ago. It was both more readable, and 20x faster. Never looked back.
- nerdponx 10y agoIn 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 10y agoThe other great thing about R is the amount of information it outputs when you run a stats function.
- nerdponx 10y agoIt'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.
- deleted 10y ago[deleted]
- StefanKarpinski 10y agoNumerical programming takes more expressive power than one might imagine. In most languages, numerical primitives like integers and floating-point numbers, and numerical operators like `+` and `[]` (array indexing), are very special and are endowed with enough magic to be usable. E.g. in C, `+` is too polymorphic to be defined as a function; in Python, `+` has special `__radd__` methods to (hackily) emulate multiple dispatch; in Java `int`, `float` and `double` are entirely different kinds of values (non-objects) from normal user-definable objects. In many ways, the fundamental premise of Julia is to design a language with sufficient power and performance that numbers are not special: "primitive" types like `Int`, `Float64` are just defined in normal Julia code, and operators like `+` and `[]` are normal Julia functions like any other. This recent post gives some more motivation: https://discourse.julialang.org/t/julia-motivation-why-werent-numpy-scipy-numba-good-enough/2236/10 https://discourse.julialang.org/t/julia-motivation-why-weren....
- deleted 10y ago[deleted]
- Tarrosion 10y agoMost 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.
- digitalzombie 10y ago> 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. Or you know.. it's Pi day.
- coldtea 10y agoToday yes. Doesn't address the "most times" the parent mentions...
- tnecniv 10y agoWhat's your working setup with Julia? I'm looking at switching over from MATLAB as soon as the semester is over.
- programmer_babu 10y agoCheck out JuliaPro: http://juliacomputing.com/products/juliapro.html http://juliacomputing.com/products/juliapro.html
- Tarrosion 10y agoMy 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++.
- blt 10y agoMonte Carlo computation of pi would be a fun addition to this post...
- simonbyrne 10y agoI actually had it in a rough draft, but didn't get it finished in time. Maybe next year.
- zengid 10y agoSo, 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 10y agoJulia 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.
- bo1024 10y agoThis 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...