9 ms·
Clay – A language designed for generic programming
- galaktor 13y agointeresting. are there any hello-world-ish examples around? struggling to find any on the page/wiki.
- lawn 13y agoFound here: https://github.com/jckarter/clay/wiki/Clay-for-C---programmers https://github.com/jckarter/clay/wiki/Clay-for-C---programme... main() { println("Hello world!"); }
- nonchalance 13y agoThat and a few other examples should show up on the homepage or an "examples" page.
- GravityWell 13y agoI was just thinking there hasn't been a new programming language announced in the last week or so. With so few existing languages to choose from that have extensive supporting toolsets and APIs, this will surely stand out.
- derringer 13y agoI feel this is a very insightful comment that adds meaningfully to this discussion. Through the use of cutting and witty satire OP has demonstrated that there is in fact an overabundance of programming languages to choose from with support and tooling, not only stating the obvious, but also serving as a blistering put-down to an individual who worked very hard to provide something useful and did it for absolutely no compensation. Good show sir. I would like to humbly request a subscription to your newsletter.
- Demiurge 13y agois it supposed to be obvious how 'clay' is useful? no problem with everyone forking everything and starting yet another language, and it doesn't have to be useful, it can be done for the experience. but if it's advertised, it would be good to explain why?
- octo_t 13y agoThe OP explains this pretty well. Clay is designed to do generics very concisely and easily.
- Demiurge 13y agoI'm not sure what you're talking about. The main page language is nice but explains it as much as a job candidates resume header explain what kind of a job candidate he is in a few sentences. There is no comparison to other languages or code examples, there are no success stories that I can see. Maybe they exist, but no, the OP doesn't explain this at all.
- steveklabnik 13y agoClay wasn't announced this week.
- Demiurge 13y agohehe, sure why not. the more, the better? :)
- gtani 13y agoInteresting, seems like this would be a good one to include in the recent go/haskell/D/rust shootout. http://news.ycombinator.com/item?id=6094668 http://news.ycombinator.com/item?id=6094668
- miloshadzic 13y agoI'm not sure why people feel the need to be an asshole here. People develop new languages, they are not all meant to be production ready from day one. If the language is not interesting to you, move along.
- X4 13y agoyes I agree, one should respect the manhours put into it and evaluate it objectively before pouring in things that give others no better overview over it. And in every language thread someone starts mentioning how good go is,.
- mratzloff 13y agoSince the website is pretty bad at giving you a high-level overview, here are two projects using it: - https://github.com/jckarter/Vinyl https://github.com/jckarter/Vinyl - https://github.com/Blei/claytracks https://github.com/Blei/claytracks I don't see anything here that would make me consider this over Go, though. Languages are rarely chosen based on their designs alone. Go is about as bleeding edge as I can get away with in my job. A big problem is lack of good, built in UTF-8 support. But the no garbage collection thing is interesting as I didn't spot any explicit allocs or frees anywhere when I skimmed.
- dottrap 13y agoGo and Clay seem to have very different intentions. Go is about concurrency. Clay is about generics. Go is garbage collected; Clay is not. This allows Clay to be more suitable in environments where GC non-determinism/performance is unacceptable.
- moomin 13y agoIt's funny that Go keeps getting mentioned when people talk about new C-like languages because as you point out, it's not actually very C-like. In fact, the only thing that I'd say was truly C-like is the ability to create standalone executables. One of the dead giveaways is that most interest in Go seems to be coming from the Python community. A better comparison would be Rust and Clay. Rust seems to emphasize correctness in the type system, Clay on making existing C++ style generics less cumbersome to use (a frankly laudable intention). On the other hand, I think it would be easier to give Rust the good things in Clay than the other way around.
- mratzloff 13y agoSure, I agree completely. But they're both systems languages. I write systems software, and Go already has barely any traction in the broader software community (outside of Hacker News...), so I have to choose what's easy to learn and has a reasonable level of support. Languages always succeed based on support (documentation, community, tooling)--not features. I brought Go up here because it stands the best chance of inheriting the role that C and C++ occupied for systems software, and which Python is also taking over. That's why it was created, so developers could have a statically-typed systems language that wasn't C or C++ or Python or Java, since all of those were unsuitable in various tasks for one reason or another.
- mkramlich 13y agoHint for all new language projects going forward: show your Hello World on the front page. A picture is worth a thousand words.
- film42 13y agoGo-lang really killed it on this front.
- laureny 13y agoActually, please do more than just "Hello world", which is not going to show how awesome your language is. Show a few snippets adding up to twenty or so lines of code that illustrate what's different about your language.
- mkramlich 13y agogood add! show Hello World. plus, show snippets which illustrate what makes your language so special. Why it's worth existing in a world that already has several pre-existing languages and ecosystems to choose from.
- lobster_johnson 13y agoHere it is, by the way: https://github.com/jckarter/clay/blob/master/examples/hello.clay https://github.com/jckarter/clay/blob/master/examples/hello.....
- AYBABTME 13y agoThis is weird: "In Clay, all arguments are passed by reference." Looks like a nest of bugs waiting to grow as new users try out the language.
- octo_t 13y agoThis is how the majority of dynamic languages do argument passing (Java/C# etc)
- AYBABTME 13y agoFor objects, not for builtins such as `int` or `double`. In Clay, when you pass `int a = 3` (or the Clay equivalent) to `increment(a)`, then `a == 4`.
- gjm11 13y agoNo, it isn't. I mean, it's possible to call what the majority of dynamic languages do "passing by reference", but it isn't the same thing as Clay does. In C#, if I do int foo(int x) { x += 1; return x; } ... int x = 3; foo(x); then afterwards the value of x is still 3. In Clay, if I do foo(x : Int) { x += 1; return x; } var x = 3; foo(x); then the value of x is now 4. I agree with the grandparent: this seems like a really terrible idea. (In fact, I was going to post a comment saying so until I saw that someone else had got there before me.) [EDITED to add: By the way, usually "dynamic languages" means "languages with dynamic typing", and Java and C# would be excellent examples of widely used languages that are not dynamic in that sense. The question of whether values are passed "by object reference" (my preferred way of describing what they do) is pretty much entirely separate from whether the language is dynamic. For instance: C++ (not dynamic, not p.b.o.r.), Java (not dynamic, p.b.o.r.), MATLAB (dynamic, not p.b.o.r), Python (dynamic, p.b.o.r). C# has the unusual feature that some kinds of mutable objects are passed that way while others -- structs -- are passed by value, with the object (in principle) being copied when the call happens.]
- Retric 13y agoYet, in c# if you do int foo(obBob o) { o.x += 1; return o; } ... Car.x = 3; foo(Car); Then Car.x = 4 which has confused a lot of new programmers. More importantly it's a more consice standard for cube(x) to cube(x) than to say x=cube(x).
- bcl 13y agoThe wiki is way more useful than the above link. https://github.com/jckarter/clay/wiki https://github.com/jckarter/clay/wiki
- andrewflnr 13y agoIn case anyone else is interested in C-replacement type languages, I've been collecting a list: ATS: http://www.ats-lang.org/ BitC (seems to be dead): http://www.bitc-lang.org/index.html Tart: https://code.google.com/p/tart/ Deca: https://code.google.com/p/decac/ Cyclone: http://cyclone.thelanguage.org/wiki/Why%20Cyclone/ Nimrod: http://nimrod-code.org/ Habit (Haskell adapted for systems programming): http://hasp.cs.pdx.edu/ Plus of course the obvious ones, Go, Rust, D. I don't keep track of these projects' usability, I just write them down as I come across them.
- qznc 13y agoHaving such a list myself, I would add: Myrrdin: http://eigenstate.org/myrddin.html http://eigenstate.org/myrddin.html Pascal: http://www.freepascal.org/ http://www.freepascal.org/ Cyclone is pretty dead.
- andrewflnr 13y agoGood catch on myrddin. I had seen it before but neglected to write it down. I didn't really know pascal was in that space at all.
- ori_b 13y agoAs the author of Myrddin, I'm kind of surprised that it's even been mentioned -- I'm not aware of it being used anywhere significant yet. (And the insignificant uses are just half-baked toy programs that I've written for myself). It's pretty incomplete, and definitely not ready for prime time yet.
- qznc 13y agoMy list is not about "useable C replacements" ;) I like to read about this stuff and compare design decisions between languages.
- X4 13y agoThank you, that's cool! I have been looking for Deca for hours in my Bookmarks and the Web, didn't remember the name. (I have collected some languages to study too)
- oconnor0 13y agoIt appears that Clay's last released update was over a year ago.
- lobster_johnson 13y agoIndeed, but the last commit was 21 days ago. Seems like it's being actively worked on.
- decad 13y agoCouldn't find any examples on the claylabs.com page but there is some in the github repo: https://github.com/jckarter/clay/tree/master/examples https://github.com/jckarter/clay/tree/master/examples
- tomp 13y agoI don't understand why modern languages still use the "mutli-value context" in place of tuples. When I first saw it in Matlab, I thought it was a mistake, and seeing it in Go and Julia reinforced this belief. IMO, tuples are superior in almost every way, as they are first-class, i.e. they act like any other values. They also avoid such sad patterns: record MyInt (value:Int); // delegate any function called with a MyInt to be called on its Int value [F] overload F(x:MyInt) = ..F(x.value); where `..` must be used to extract multiple values in a single-value context. This could easily avoided using tuples. The only advantage of Matlab-style multiple values is that they allow a kind of return-value type overloading, i.e. some Matlab functions perform less work if you don't only consume 1 return value. But I believe that this could be easily solved with a first-class code pattern.
- codebaobab 13y agoMaybe modern languages don't have tuples because modern programming language designers don't have any|much|enough experience with tuples? If I wanted to play with tuples, what language(s) would I have to use?
- oblique63 13y agowhat about python?
- tomp 13y agoPython, or any of the functional programming languages: OCaml, Haskell, probably Scala. Tuples are really just syntactic shortcut for immutable lists, so Clojure would be appropriate as well, even though it makes no distinction between a tuple and a list (e.g. "rest" parameters to a variadic function are a list).
- lobster_johnson 13y agoWhat exactly do you mean by "multi-value context" and indeed "tuple" in this case? A tuple is traditionally an ordered list where the positions may or may not be assigned a name. When we assign names to the positions, we tend to call them "records". In other words the tuple [30, "Bob"] and the record {age: 30, name: "Bob"} are equivalent. One language that prominently relies on tuples with unnamed fields, in the absence of a built-in record syntax, is Erlang. The downside to not having names is that to find a value you must know its position, which hides information in the implementation (refactoring the code in a way that changes the position, for example, might not result in a compile-time error), which is one reason that Haskell provides syntactic sugar for expressing tuple types using a record syntax. One thing that Go does right is to sometimes allow you to address a record as a tuple: var x SomeRecord = {1, "Bob"} However, when reading, I believe (I haven't actually checked) you can't access a record variable as a tuple.
- nairteashop 13y agoHere's a Q&A thread with the creator of Clay, KS Sreeram (a good friend of mine from back in the day): http://www.reddit.com/r/programming/comments/ctmxx/the_clay_programming_language/ http://www.reddit.com/r/programming/comments/ctmxx/the_clay_... It's over 3 years old so a lot of it is probably out of date, but still interesting to see the thought process behind the language design.