Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I quite like the lua syntax as-is.

It's simple, predictable and easy to read.

This obsession with boiling everything down to strings of symbols is how folk wind up making fun of Perl and OCaml.

What's this do?

    $$&[%]
Or this?

    ?:>
Buggered if I know. Only a professional Perl or OCaml programmer could tell you -- and indeed I made those up. Only a professional Perl or OCaml programmer could tell if they do anything at all.

But pretty much anyone from any language background can eyeball an Algol-family syntax and tell you what's going down.



I wonder why you got OCaml involved... from my experience, OCaml is one of the cleanest languages known, sure there are a few special symbols and operators, like :=, :: and +., but there are relatively few, so you just learn them like you would in any other language (e.g. C has ?:, == and ++).

Sure, OCaml allows you to specify new operators, but the rules are pretty simple, and you cannot arbitrarily fuck up the syntax.


I think you must be confused. OCaml is not all that punctuation heavy and doesn't have overloaded operators to make it punctuation heavy.


I must be, but here's how I remember it (bearing in mind that memory is faulty).

A few years ago I took a unit in my comp sci degree, "Programming Paradigms". The language used for teaching was F#, which is heavily inspired by OCaml. At one point we were given readings on OCaml programs and a particular operator popped up -- something like "is subtype of", I fail to recall exactly -- and it looked like :>? or :?> or similar.

I bitched loudly in the unit forum about this operator, whereupon the professor politely informed me that he, in fact, had invented that little bit of syntax when he was a PhD student at INRIA.

He didn't flunk me! Dr Rowan Davies, still the most scary-smart computer scientist I've met.


I haven't ever seen that in OCaml. Probably an F# extension.

If you're going to complain about OCaml's syntax, I would start with having to use different arithmetic ops for int vs. floating point (+ vs. +.) and different indexing operators for strings and arrays ( s.(0) vs. s.[0] ).

You get used to it pretty quickly, and OCaml more than makes up for it in other ways, but it is a bit annoying.


He mentioned that he did a bunch of work object-system work on Caml that was published, but the INRIA guys didn't put it into the main version when they developed OCaml. It's possible it got transmitted into F# that way. Next time I see him I'll ask about it.


On rereading, I realized this might give a false impression. OCaml does allow the user to define an operator, but a confluence of the type system (which doesn't allow overloading and makes abstracting types sufficiently difficult that it doesn't justify the minor syntactic nicety of a custom operators) and precedence rules means that most OCaml code you'll see does not use a lot of weird operators like you'll find in advanced Haskell code. I'm not an OCaml guru, but that's what I've seen.


Not OCaml per se, but at least one F# library makes liberal and very effective use of custom operators: FParsec, Stephan Tolksdorf's parser combinator library (http://www.quanttec.com/fparsec/reference/primitives.html). Of course, FParsec is adapted from the Haskell Parsec library, so maybe that just makes your point for you!


1.0 + 2.0 <- Not valid OCaml! :)

But I love OCaml, I don't why it isn't more hacked/forked.


> But I love OCaml, I don't why it isn't more hacked/forked.

Because it has a fucked-up licence - you're not allowed to "fork" it in the usual sense of the word, you can only distribute the original source, and your modifications in a patch. The "free-for-all" licence is only available to commercial users.


That's quite a bit of an exaggeration in this case. Look at the simple syntax for OOP or default argument values. That's a lot of cruft removed compared to Lua. The less you need to read the better, as long as it's readable.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: