Anic - Faster than C, Safer than Java, Simpler than *sh
code.google.com
code.google.com
I work on System S, which is the research name of IBM's InfoSphere Streams, which is a distributed, realtime (edit: soft realtime; so, high throughput, low latency, but not hard realtime with guaranteed deadlines) streaming system with an associated language. Another project in this area is Storm. See this comment thread for more on that: http://news.ycombinator.com/item?id=3193115
But, Anic seems to be more related to the kind of streaming languages that came from the digital signal processing and embedded worlds. See, for example, the StreamIt project: http://groups.csail.mit.edu/cag/streamit/
In particular, a StreamIt tutorial: http://groups.csail.mit.edu/cag/streamit/papers/streamit-coo...
Note that Streams, Storm, Anic, StreamIt all have the same underlying programming model, but Streams and Storm target a different area than Anic and StreamIt. Streams and Storm target the emerging area of "big data" where you need to distribute your computation across a cluster. Anic and StreamIt are lower level: applications such as video decoding are streaming in nature, but one typically implements them on a single chip, and often even in hardware.
Standard disclaimer: my views are not official IBM views.
You would learn a lot and that would make you a better programmer.
That is not exactly selling the language.
Saw that, closed the page.
[]{
Already, the syntax is starting to look a little strange, but OK, I'll give it a shot. id = [int\];
Hm. Backslash seems to be used for something other than escaping. Not a good sign. =;
Huh? The equals operator is being used alone, with nothing on either side? That's really stretching the bounds of convention. -> --> <-> <-
We have various types of arrows that are used as syntax. In some cases, they're used as binary operators, in some cases as unary. Doubling up of dashes appears to change the meaning. This is really not looking good.And then there's the example you mention. Besides how it looks; their example of solving a useful concurrency problem is "a bug-free, efficiently multithreaded real-time clock + infix calculator hybrid application"? Why would you even want that?
There may be something interesting here, but between their quite bizarre syntax and poorly chosen examples, they aren't doing a very good job of hooking me.
From the tutorial[1]:
In ANI, \ means "latch". Basically, a latch is a place where you can "hold on to" an object of the specified type. A latch is like a box that you can put things in to, take things out of, and peek at what's inside.
Forward slashes are for prefixes, backward slashes are for postfixes. Nice parallel there :)
At the very least, people should approach new languages from an ease of typing angle. I look at that and all I can think is "That would be a bitch to type out. Doing it all day? No thank you."
Anyway, to answer in the affirmative: Certain paradigms provide from certain syntax. E.g. Haskell would be much clunkier to write in a C-like syntax than with the ML-derived one it has. And Lisp's macros would be harder to pull off with a different syntax. In my opinion, Python also profits from syntactic differences with C.
Somebody more knowledgeable could talk about SQL-syntax.
> At the very least, people should approach new languages from an ease of typing angle. I look at that and all I can think is "That would be a bitch to type out. Doing it all day? No thank you."
Old languages would also benefit from that approach. We've seen some alternative syntaxes JavaScript, but not really for something like C.
One part of me says "Don't reinvent the wheel", but the other part of me suspects that forcing a new language to follow the syntactical conventions of another language that was designed with different considerations in mind is a bad idea.
The best example of a language that I think suffers from it's association with the syntax of another is C++. The features that it provides are all more or less fine, but cramming it into a syntax that was made for a much simpler language really wasn't a good idea.
(I understand why it was done from a historical perspective, and understand the few benefits it affords, but I think those are particular to that example)
On the other hand again, there really isn't a lack of syntaxes these days that a new language developer can look to for inspiration. Surely one of them should work fine most of the time.
S-expressions?
NB I once got paid to write Lisp, C and PostScript on the same project, if nothing else it taught me to be somewhat flexible about language syntax.
* C -- line-continuations (important for macros).
* Perl -- regex back-references.
* Haskell -- anonymous functions.
* Python -- line continuation.
* Tcl -- line continuation.
* Icon -- non-null test (unary), generator limitation (binary).
* Prolog -- \+ for not provable.
* J -- the prefix adverb and the grade-down verb (\:).
* TeX -- Yes.edit: oh yeah.
$\ - The output record separator for the print operator. If defined, this value is printed after the last of print's arguments. Default is undef.
Thus: /\b(\w+)\W+\1\b/ means "match repeated word".
And: /\b(\w+)\W+$1\b/ means "match word preceeded by the word matched on your last match.
Moving on: s/Hello (\w+)/Goodbye $!/ means "Replace Hello followed by a word with Goodbye followed by the same word."
And finally: s/Hello (\w+)/Goodbye \1/ is special cased to mean the same thing, but is frowned upon.
I posit that line continuations don't count, at least not in the "rely heavily" category.
Then I am not sure how popular J and Icon are. So let' keep those away. Is the backlash really used that often in Prolog? I wouldn't say "heavily". So that leaves us with:
* Perl
* Haskell
* Tex
I think that's a more realistic "rely heavily" category.(I'm also German and switched to American Dvorak earlier. I only heard about Neo later, and am too lazy to switch now.)
(Plus since I don't type much German, I don't need quick access to üöäß, though an English-centric variant of Neo would be.. interesting, maybe using those keys for the most common programming symbols?)
ANI is a very different language to C. Using a C-like syntax wouldn't make sense.
C's syntax is a fairly low level, which makes it fairly easy to map to assembly, but not very well suited for representing high level constructs (see C++).
Note: This is production code.
// remove more clutter
#define O printf
#define R return
#define Z static
#define P(x,y) {if(x)R(y);}
#define U(x) P(!(x),0)
#define SW switch
#define CS(n,x) case n:x;break;
#define CD default
Thanks for that. The comment makes it classic.:)
I imagine searching for Z, R and O in a large code repository.
http://code.google.com/p/anic/wiki/Tutorial
I thought the idea of Streams was interesting and appreciate OP for posting this.
This is a free creation by someone out there who gave their time to do something harmless, useful and freely shared.
But unfortunate part of sharing is also receiving criticism.
Sometimes criticism is stronger when the initial expectation is higher. I think most clicking that link got excited about all the features they read before then they got disappointed when they saw that piece of code.
So his job is not to babysit other techies, i.e. he doesn't care about how others see this project, so then he wouldn't mind the criticism either, right?
I'm not saying this language does a good job at that, but to dismiss something interesting just because of syntax prejudice is shortsighted.
Mostly, when I come across complex equations in CS papers, I tend to skip over them and only go back to look at them if there are parts of the paper I can't make sense of without them - it is very rare to find that they are necessary at all.
The cases where I find I need them are usually a sign of trouble - it tends to mean there'll be a lot of guesswork to figure out parameters and parts of the algorithms that are not spelled out in the paper at all. But usually the same ideas will be expressed in English, code or pseudo-code in much simpler ways.
My research for my MSc involved a bunch of papers on error correction in OCR, including a ton of image processing and statistical analysis, and not one of the 50+ papers I reviewed actually depended on the equations present in them for understanding the ideas, but I quickly learned to appreciate the ones that were light of equations for the seemingly substantially higher odds that the algorithm descriptions would be pretty much complete and precise.
But without such obfuscation, how would CS PhDs retain their competitive advantages?
I mean, if anyone could just read your paper and actually implement the algorithms that you talk about there without having access to your base code and the real details that you didn't publish, then they might scoop you on the next (quite obvious) iterative improvement to your algorithm without having to do two years of preliminary work. And then you'd only get one paper out of it, whereas by obfuscating the hell out of the thing, you can milk it for five or six.
Obviously any equation can be expressed in words, but those who are familiar with the notation are able to read the equations and understand the ideas in a paper in a fraction of the time. This is important for those who read papers regularly.
It is like showing obfuscated C to someone you are trying to convince to look at C
I think some of the language's concepts are pretty neat and unusual.
I just highlighted that the choice to present the most obfuscated and hard to read (and by number of upvotes it seems that most agree) piece of code on the front page of the language is not helping appeal to that second (subjective) part it drives people away before they even get to click on the the tutorial (which explains what is what).
Uncomfortable syntax can be excusable if you have a clear rationale for it, but I can't for the life of me see why this syntax would need to be this awkward.
At this point I shudder at the thought of having to maintain any of that code. I'd even prefer to work on the C I was writing in high school.
What I don't understand is that writing a stream that unlatches a "variable" (a thing bound to a latch) executes once per time the variable is set, but it's not clear why the same code bound to a constant doesn't loop infinitely.
i.e.
i = [int\] <- 10; \i -> std.out;
executes once because i was set once.
i = [int\] <- 10; i -> std.out;
executes once because...
God forbid we should need to learn any new syntax or shudder concepts! The old ways are the best ways.
If the example code doesn't look INSTANTLY, IMMEDIATELY awesome and amazing, it isn't worth a second glance. Even the first glance was a horrible waste of time!
If I read that wrong though, then my apologies.
That said...
I feel like this streaming syntax might be better suited as a meta-programming framework of sorts...build the more intricate objects/modules in a language such as C/C++ or java, and use these stream/latch metaphors to orchestrate those modules.
Yes, you can already do this with *sh (largely the point of Unix pipes), or directly in C/C++/Java (e.g. Storm), but ANI seems to provide a really rich interface for this kind of orchestration. It has many of the right primitives.
I think that is why the criticism is more apparent. It is exciting to have those features, but then the syntax just pushed you away.
I was briefly involved in this project, I wrote some code for instruction selection, was active on the mailing list and had a few lengthy discussions about dataflow programming with Adrian/Ulitmus. Last I heard, in early 2011, he was still working on it, but in private, and he had changed focus somewhat to something even more ambitious. I voiced my concern over raising the bar before the first simpler version was released and feature creep, but I guess his mind was made up. I haven't heard anything since, despite trying to reach him a couple of times :-(
So, from this, I would say that ANI can safely be assumed dead unless a working compiler is surprise-released.
I dunno, mlton was of that order and that was ages ago.
Nevertheless, for a modern take on a dataflow language, ANI is intriguing. If nothing else, the paradigm is probably different enough from imperative/OOP/functional that it is worthwhile to learn even if ANI doesn't take off.
Wait, what? Why...?
Sorry.
Anyway, the components that you would need to build such a thing are certainly all available.
> Q: Why are backslashes (\) used as language operators? Isn't that confusing, given they're used in other languages as escape characters?
> A: This is a valid point, but backslashes were chosen for a purely pragmatic reason; on virutally all keyboards, backslashes are very easy to type (requiring only a single keystroke). This is a handy property for backslashes to have because in ANI, you'll be typing them a lot!
> Incomers from other languages might be thrown off a tiny bit, but a programmer that's spent some time with ANI will quickly come to realize that there is actually never any good reason to end a line of ANI code with a syntactual backslash! If one insists on doing so anyway, they are writing ill-formatted code that would be confusing regardless of how backslashes are interpreted by the language. Thus, the backslash conflict is there in theory but irrelevant in practice.
> The usage of \ in the language syntax is a thought-out practical compromise, though the issue may be reconsidered in the future depending on programmer feedback.
To see what the backslash does, see the Pipes section: http://code.google.com/p/anic/wiki/Tutorial
Edit: I'm not defending these arguments, simply pointing out that the developers have put forth some reasons.
That's such a typical US-centric attitude. On (most?) European Apple keyboards, "\" is alt+shift+7 or some similar Vulcan death grip combo. Not exactly "very easy to type".
Going out of your way to produce such small and dubious improvement is always a bad idea imho.
If you really think C syntax is a pain point, the sanest thing to do is to go with textual keywords like in ruby or lua.
Why?
"Hello World" to std.out
That's just an idea I had on the spot, not sure how it would play out. But I
think this stream programming would actually lend itself well to some sort of
literate syntax. \arguments -> body
to Scheme's (lambda (arguments) (body))
because it stands out more. What gives me as the reader an even better hint without getting in the way, is indentation. That's why I prefer that to e.g. curly braces for reading. (Writing, especially in non-programming editors, like a webform, is easier with explicit markers like `end' or } though.)If you were serious about making things easy, you'd look at all the common keyboard layouts (not just American ones) before choosing a "thought-out practical compromise" that is of dubious practicality.
DOS and Win9x were particularly disgusting: C:¥DIR¥SUBDIR¥README.TXT
It's regarded more as a necessary evil than anything else. Any language featuring it prominently will be unlikely to achieve much popularity in Japan.
Also, in C, you can just type ??/ instead of backslash.
amespace ragedy
followed by
* getChopsticks = [--> ?] { \chopstick, \nextPhil.chopstick --> }; *
is just dripping with irony.
http://news.ycombinator.com/item?id=1898573
sigh I still can't get past the syntax..
Is there a repository of sample code? I'm curious about how interacting with the filesystem, network, graphics would look like.
http://code.google.com/p/anic/source/list http://code.google.com/p/anic/w/list
One other thing: anic is buzzword-compliant.
Haha. The entire point of programming is to tell the hardware what to do. Any programming language that is not 'high-level assembly' has severe leaky-abstraction problems. The reason C and C++ still enjoy so much success despite limited syntax is that they stay true to the hardware and don't force another layer of abstraction on you.
The syntax looks awful and confusing
Really. It's a pain to type []{} and \ on a german keyboard especially if it's supposed to be like every second character! Stop it. Please. Especially when there are proven languages that can cope without all this sh*t (yes, i am looking at python here).
Edit:
Although this might be an interesting language there is no way i am going through this syntax just to "check it out". Lost an opportunity to gain a new community member.
Anyway, the reason I ask is because I wanted to know what this line does:
=;[1]: http://code.google.com/p/anic/source/browse/src/parserGramma...
https://en.wikipedia.org/w/index.php?title=Dining_philosophe...