6 ms·
> a=[int\]<-0; op=[char\]<-' '; b=[int\]<-0; r=[int\]<-0; 0 { clock => [int ms] { ("\r" + ms/1000.0 + ":" + a + op + b + "=" + r) ->std.out; 1 std.delay (ms+1)
by rdtsc 14y ago
> a=[int\]<-0; op=[char\]<-' '; b=[int\]<-0; r=[int\]<-0;
0 { clock => [int ms] { ("\r" + ms/1000.0 + ":" + a + op + b + "=" + r) ->std.out; 1 std.delay (ms+1) clock} };
inLoop => {\std.in->a \std.in->op \std.in->b inLoop};
\\op ?? {'+': (\a+\b) '-': (\a-\b) '': (\a\b) '/': (\a/\b) : 0} <->r;
That is not exactly selling the language.
Saw that, closed the page.
- hamai 14y agoMaybe the tutorial would be a better first impression: http://code.google.com/p/anic/wiki/Tutorial 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.
- rdtsc 14y agoThere is obviously a lot of effort put in it. The idea behind it is so cool. He shared and put it up. That's very good. 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?
- fsaintjacques 14y agosame here.
- mrcharles 14y agoI'll never understand why people keep going out of their way to make new weird syntaxes. Is it really necessary? Does it really give something over well established C-like syntaxes? 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."
- jurre 14y agoEase of reading I hope!
- jlgreco 14y agoI have too seemingly opposing thoughts on this. 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.
- terhechte 14y agoThis specific one is just bad though. I mean "\" is really difficult to type on almost all non-us keyboards. It's not even really easy on US keyboards (the pinky has to go a long way). See how often it's in there. Even standard C syntax is a pain on some non-us keyboards. I.e. on a German keyboard, the [, [, {, }, are rather difficult to type. That's why I (being German) switched to an English layout around two years ago. Now I have trouble typing umlaut and thus writing good German, but at least my coding speed improved by probably 50% and my Hand hurts far less.
- 14y ago
- bunderbunder 14y agoThat particular snippet caused me to have a bad flashback to the days when I admired Perl for its terseness and "expressivity". 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.
- rdtsc 14y agoAs I say. There is write-once code. When I write it and nobody else can't read it. Then there is worse, there is wire-once and even I can't read it.
- RivieraKid 14y agoApparently, you didn't read the line above the code, saying that this is a compacted version. If you removed whitespace from a C code, you would get something that is even worse.
- mikeash 14y agoWhy would you showcase a compacted version of the code...?
- RivieraKid 14y agoI guess he was trying to demonstrate what you can achieve with a small number of characters. It may not be a good idea from a marketing perspective but come on... "Saw that, closed the page" is simply narrow minded.
- eswangren 14y agoIt's not a good idea from any perspective. In my experience, the only people who cram as much logic into as few characters as they possibly can are beginner to intermediate level programmers who are in that awful phase where they think they know a lot more than they do.
- rdtsc 14y agoMy point was that displaying that on the front page about your language is not going it any good. It is like showing obfuscated C to someone you are trying to convince to look at C
- RivieraKid 14y agoIt's just a little dense to demonstrate the succintness of the language. The 2 samples above are normally dense. I really don't see the problem. It's not clever to make a judgement about a language (whose syntax you don't know) just because you don't like some sample of it. I think some of the language's concepts are pretty neat and unusual.
- DannoHung 14y agoLOOK UPON MY WORKS, YE MIGHTY, AND DESPAIR: http://kx.com/q/c/c/k.h http://kx.com/q/c/c/k.h Note: This is production code.
- bronson 14y agoOo, where'd you get the C minimizer?
- DannoHung 14y agoThis is the way that APL programmers write C.
- iskander 14y agoJesus, my research project once depended on this file. The day we deleted it from the repository was a very happy one.
- rdtsc 14y agoThat was a fun search and replace exercise I bet... ;-) I imagine searching for Z, R and O in a large code repository.
- scott_s 14y ago// 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.
- tadfisher 14y agoorz: the person maintaining this code :)
- nicholassmith 14y agoIt made me scrub my eyes and go 'buhhh?'. I'm all for new languages trying new things with new syntax and design choices, but make them half decent.
- podperson 14y agoAgreed, but the tutorial is actually quite good and the syntax (mostly) makes sense to me now. 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...
- eru 14y agoThe dining philosophers example doesn't look too unreadable on first glance.
- rdtsc 14y agoYeah that was ok, but why put this obfuscated code on the front page?
- ricardobeat 14y agoReading the tutorial (http://code.google.com/p/anic/wiki/Tutorial http://code.google.com/p/anic/wiki/Tutorial) is a less unpleasant experience.
- jetti 14y agoI agree. After reading the tutorial, I want to try this out. It looks like fun.
- vidarh 14y agoBut after skimming over the tutorial my impression is that the concepts are so simple there's even less excuse for that horrible syntax. 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.
- lambda 14y agoYeah, I'm having to fight really hard to continue giving the language a shot after seeing that syntax. Let's see, from their Dining Philosophers example: []{ 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.
- ams6110 14y agoHm. Backslash seems to be used for something other than escaping. Not a good sign. 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. [1] http://code.google.com/p/anic/wiki/Tutorial http://code.google.com/p/anic/wiki/Tutorial
- tedunangst 14y agoThe only thing worse than using backslash is using postfix backslash...
- MartinCron 14y agoIf it weren't for the long-running convention of using backslashes as escape characters, postfix backslash would make some kind of sense, at least visually. Forward slashes are for prefixes, backward slashes are for postfixes. Nice parallel there :)
- ThePherocity 14y agoAgreed. Here is a suggestion to budding syntax creators: If 90% of the code is written by your pinky finger; stop. You're doing it wrong.
- azakai 14y agoOf course, every new language should look exactly familiar to us users of existing languages. 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!
- peeters 14y agoYou're attacking a strawman. OP never said that any new syntax is bad.
- azakai 14y agoI admit I was snarky and maybe jumped to conclusions ;) But it sounded like OP took a look at the syntax, had a quick visceral reaction to it and closed the tab. If I read that wrong though, then my apologies.
- ams6110 14y agoOn the other hand there's something to be said for terseness. Ever read a math or CS paper that's full of equations and other graphical shorthand? To the uninitiated, it's gibberish. Once you learn the conventions, it's a way to communicate complex formal ideas with very concise notation. I'm not saying this language does a good job at that, but to dismiss something interesting just because of syntax prejudice is shortsighted.
- justincormack 14y agoMaths is not about conventions. It is a dynamic writing style. All operators get replaced by adjacency after a few lines as writing them is boring. Computer verifying proofs is very hard for notation reasons.
- vidarh 14y agoPretty much every CS paper I've read that was full of equations could have easily done without them. There certainly are sub-fields of CS where complex equations in papers are justified, but far too often it is laziness, and hides assumptions or imprecise descriptions that makes implementing the described methods harder. 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.
- bermanoid 14y agoThere certainly are sub-fields of CS where complex equations in papers are justified, but far too often it is laziness, and hides assumptions or imprecise descriptions that makes implementing the described methods harder. 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.
- bakkdoor 14y agoOn a german keyboard \ is not just "a single keystroke". What a pain -_-
- spartango 14y agoThe syntax put me off at first, and still bothers me a bit (something to do with too much symbolic sugar and existing familiarity with escape chars) 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.
- rdtsc 14y ago> feel like this streaming syntax might be better suited as a meta-programming framework of sorts 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.