3 ms·
Is it? The asymmetry of function definitions seems really ugly to me: f(x) = x * x function(x) x * x end function f(x) x * x end f = x -> x * x If
by mruts 7y ago
Is it? The asymmetry of function definitions seems really ugly to me:
f(x) = x * x
function(x)
x * x
end
function f(x)
x * x
end
f = x -> x * x
If Julia just used curly brackets instead, we wouldn't need all of these different ways to declare functions.
It really have been nicer if I could just do:
{ x -> x * x }
or for named function:
def f(x) { x * x }
- eigenspace 7y agoOptions two and four do different things than options 1 and 3 so those aren't really relevant to the discussion. Options one and three are both good to have because sometimes you want one-line function definitions (mostly when you want your code to look like math) and sometimes you want big standard 'code looking' multi-line function definitions. If you don't want to choose in the future, just choose one now and stuck with it. Both can be used for everything if you're willing to put up with some awkward syntax. f(x) = begin x * x end If this is your main complaint about julia, I'd say we're doing pretty good. Curly brackets are useful notation and it'd be a waste to use them up for something like this.
- mruts 7y agoIt seems like the core of the issue has to do with array indices vs function application. Julia uses curly brackets for type parameters because it can't use brackets because they are taken for array notation. But what's wrong with less than or greater than for type parameters? If it's followed by colons for contravariant/covariant types, I don't see why it can't be used for both. Julia's great, but the Pascal-like 'begin and 'end' delimiters strike me as incredibly ugly. There are many alternatives that I can see (such as the one I mentioned above) that would obviate this situation. I consider myself a 'mathy' person (I work as a quant), but even so, Julia is a very odd language. All of these compromises or whatever just to please the math people who have a hard time programming. Some of these things the more I think about them are great (array indices starting at one make a lot of sense, actually) and the ability to just write '2x' instead of '2*x' is growing on me. I guess I don't know what my point is. Maybe it's that Julia seems a little alienating for CS types, and that might hamper adoption. All in all, Julia's pretty great, despite the minor quibbles I mentioned. I sure as hell wish I could use it for quant work instead of being stuck with the vastly inferior Python.
- patrick5415 7y agoWell the target user of Julia is the mathy/sciency people, not the cs folks, as far as I know...
- StefanKarpinski 7y agoThat would have been a criminal waste of a very valuable pair of matched ASCII brackets. C++ ran out of ASCII brackets (because of using them for blocks), was forced to co-opt inequality operators for templates, and has suffered from terribly fragile syntax as a result.
- mruts 7y agoI mean, you could use \ and / for type parameters. Or even parens (Julia doesn't support Scala like double parameter lists as far as I know). What makes Julia so unique that it needs to make different choices than virtually every other modern language? (See my above comment for more clarification).