8 ms·
The Claro Programming Language
- yashap 3y agoPretty interesting! signa11, are you the author of the language? If so, is it fair to say the “closest competitors” for this language would be Kotlin and Scala? If so, what do you see as the pros/cons of Claro vs. these two languages?
- mdaniel 3y agoI would have guessed it took inspiration from rust with the `mut` keyword, and then told rust to hold its beer since mut is not transitive so `int[][]` would require `mut mut` to be able to write to int[0][1] if I understand TFM correctly : https://docs.clarolang.com/static_typing/builtin_colls/builtin_collections.generated_docs.html#mutability-annotations-are-shallow https://docs.clarolang.com/static_typing/builtin_colls/built...
- mdaniel 3y agoInteresting, although it seems to currently be missing a license. While Bazel and I are for sure not friends, I found this funny https://github.com/JasonSteving99/claro-lang/blob/v0.1.495/WORKSPACE#L124 https://github.com/JasonSteving99/claro-lang/blob/v0.1.495/W... I guess it's similar to having a maven build under Nix but my relationship to Bazel is why I got a chuckle out of the russian doll setup
- quantified 3y agoThe Bazel linkage will be a bit polarizing.
- jvolkman 3y agoThis is just fetching external dependencies from Maven repositories, not using it to build artifacts.
- SkyMarshal 3y agoThis sounds interesting: > Claro’s declarative, DAG-based structured concurrency model provides an easy-to-use abstraction to statically guarantee that programs are: Non-blocking Data-race free Deadlock free Optimally scheduled Scalable by default Any language that can simplify the static guarantees of all those is worth a look.
- kaba0 3y agoI don’t think deadlock free is possible without some very serious limitations. Like not even share-nothing, communicate via messages only is safe from deadlocks.
- bmitc 3y agoYou can deadlock processes in Erlang/Elixir, but as far as I know, that deadlock will not block all the other processes running.
- kaba0 3y agoI mean, that’s how it works in Java as well (other threads keep running), but you are not much helped if your “critical business logic” deadlocked and doesn’t do its job. Though I guess you can try restarting it with Erlang.
- saghm 3y agoFrom glancing over their guide, it seems like it achieves this by essentially requiring you to manually specify a state machine that it can verify won't cycle by composing together "graph functions" that return futures (which are not allowed to block on the results of any futures directly or transitively). If I understand correctly, combining this with only allowing immutable data to be shared (like you described) makes it possible to parallelize graph function calls when that don't depend on each others results.
- kaba0 3y agoWell, that’s true. Though then it is pretty similar to the “build tool” problem, which is actually an interesting parallel :D Nonetheless, I do think that big limitations at most places, with optional, explicit escape hatches is a good pattern.
- bbkane 3y agoVery interesting and I love how much thought the author has put into the build system. I don't like the separation of of interface and implementation at the file level. I feel like having to type the same thing twice header-file-style really slows down development iteration speed.
- jasonsteving 3y agoI'm glad you've found Claro interesting so far! I can understand where you're coming from with the split between API and impl. It's certainly something I'm keeping on my radar. Personally I care more about readability than writability so it's not a big issue for me, but I can understand that others would land differently on this point. One reason that I'm holding out on this (for now) is that I'm actually excited about how this one decision makes it quite easy to express some quite complex patterns using "Build Time Metaprogramming": https://docs.clarolang.com/metaprogramming/code_reuse/reusing_module_apis/reusing_module_apis.generated_docs.html https://docs.clarolang.com/metaprogramming/code_reuse/reusin.... The whole section is really more of an exploration than it is any sort of strong statement that this is what all Claro code should look like. But it's all fundamentally enabled by this "physical" separation between API and impl.
- dudalev 3y agoThe logo resembles heptapod writing from the Arrival
- otikik 3y agoApparently its literal meaning is "offer weapon". Source: https://twitter.com/Emma_Hollen/status/1340402040070156299 https://twitter.com/Emma_Hollen/status/1340402040070156299 Perhaps the intent here is for it to mean "offer tool", though.
- alpaca128 3y ago> Apparently its literal meaning is "offer weapon". In the movie this exact translation turns out to be wrong.
- travisgriggs 3y agoI went reading to see if this was some evolution of Pharo. It is not. I paged through about 20 of the pages. Have we reached a point where “new computer language” means variation on a theme, same pigs, different lipstick? Nothing negative meant. It all looks decently thought out and pretty otherwise conventional. Kind of like yet-another-marvel-movie. It’s different, but it isn’t really. I miss the days where “new language” meant different ideas and models. Like when it was Scheme and Forth and C++ and Pascal and Ada and ML and Fortran and Smalltalk and Lisp and Eiffel and Beta and Prolog and Self. Those were much more varied days.
- Garlef 3y agoCheck out Unison and Winglang.
- klyrs 3y agoI dunno, @mdaniel's comment points to a potential gamechanger in the evolution of rust-inspired languages. I'm not a rust expert but fine-grain mut seems like it could reduce the performance cost of safety, or at least, make it much easier to avoid paying that cost unnecessarily. Big motions in language theory should probably be expected to diminish in frequency as the field matures. Not every new language needs to do that. Just about every language developer has their own pet language, often more than one. It's a good thing. It's how the field advances.
- bmitc 3y ago
- lf-non 3y agoThis is very interesting, but I don't see any section in the docs about JVM interop. I am curious what is the effort needed to use a library written in java (and potentially other jvm languages) in claro.
- elbear 3y agoIf the author doesn't read this thread, maybe you can open an issue with this topic. I think other people would be interested in this, so maybe the author prioritises it.
- jasonsteving 3y agoGreat question! This is actually something that will take more work to pull off "right" - but it's definitely planned. For now, Java code can call into Claro code in a fairly straightforward way. The main hurdles are: - the namespacing/naming of the Claro code you're calling into is funky because Claro doesn't use Java's "package" namespacing system - manually constructing non-primitive data to pass to Claro procedures is currently very annoying and, more importantly, unsafe (you could break Claro's type system rules) In the other direction, Claro's only (current) mechanism for calling into Java directly is restricted to the stdlib's implementation. For example the deque Module[1] exports an `opaque newtype mut Deque<E>` that is actually just a `java.util.ArrayDeque<E>` underneath[2]. The reason this isn't exposed to Claro programs outside the stdlib (yet) is because: - the type systems are very dissimilar and would need mapping - Claro doesn't use Exceptions, so you'd have to ensure that any calls into Java code that can throw manually catches and models an error return value[3] All this said, it's very possible that in the future these limitations can be addressed! [1] https://docs.clarolang.com/stdlib/deque_module.generated_docs.html https://docs.clarolang.com/stdlib/deque_module.generated_doc... [2] https://github.com/JasonSteving99/claro-lang/blob/b5e33ae4ef06126c5b99af90b84abe8c2b383a98/stdlib/deque/deque.claro_internal#L2 https://github.com/JasonSteving99/claro-lang/blob/b5e33ae4ef... [3] https://github.com/JasonSteving99/claro-lang/blob/b5e33ae4ef06126c5b99af90b84abe8c2b383a98/stdlib/deque/deque.claro_internal#L157-L161 https://github.com/JasonSteving99/claro-lang/blob/b5e33ae4ef...
- tomp 3y agoI hate it that so many programming languages lie to users. > We don’t support exceptions, all errors must be declared and manually propagated > however, `panic` Like, just admit you support a poor man’s version of exceptions. Similar to how Go took a decade to admit that (1) generics are useful, and (2) generics are already supported, by builtin types
- heinrich5991 3y agoI think there's a difference in culture between panic and exceptions. Panics are usually reserved for violated invariants, programmer errors. Exceptions are used for normal errors.
- otikik 3y ago"What are exceptions used for" is similar to tabs versus spaces. Many languages just "leave that part to the user". Which I think is wrong. Or at least, inefficient. Different people will make different assumptions and then we will have a clash of opinions.
- davedx 3y agoYeah, the amount of bike shedding and yak shaving I've been pulled into over "how exceptions should be used" is pretty dismal. The worst thing is, I've still not even 100% decided myself. I think that does say something about the design of exceptions.
- shrimp_emoji 3y agoThey should not be used.
- davedx 3y agoWell I definitely disagree on that. I fall more on the side of “use them for regular errors too” because IMO anything that reduces boilerplate is a good thing. But I also don’t like “magic” so it’s still a bit in tension in my head
- asimpletune 3y agoI'm extremely impressed with what the they were able to accomplish. The language seems to be elegantly designed and with strong opinions in interesting places. I'm really looking forward to see how it develops in the years to come.
- jasonsteving 3y agoThank you for the kind feedback!
- davedx 3y agoThere's some really cool ideas in this, and I love how you're straight into the documentation with examples. Great job. I raised my eyebrows at this part though where the type constraints part was being explained: > Coming from an Object-Oriented background, you may be tempted to compare Contracts to "Interfaces", but you'll find that while they may be used to a similar effect, they are not the same thing. The intention of an "Interface" is to encode subtyping relationships between types, whereas Claro has absolutely no notion of subtyping. [1] IME with e.g. C#, interfaces are exactly for this kind of thing? Abstract classes and classes are more used for polymorphism? But I admit it's been a while since I worked with C# and I may be remembering this stuff wrong. [1] https://docs.clarolang.com/generics/contracts/contracts.generated_docs.html https://docs.clarolang.com/generics/contracts/contracts.gene...
- neonsunset 3y agoC# interface is kind of like Rust's trait except the default passing convention by interface is similar to Box<dyn Trait> whilst passing structs implementing interface via generic arg is identical in the form of Accept<T>(T value) where T : ISomeInterface. Arguably, today the line is somewhat blurred because interfaces can have default member implementations (which are used to extend interfaces without making it a breaking change) but generally you are correct. An abstract class and subclasses that inherit from it signifies what the type is while the interfaces a class or struct implements signify what the type does.
- jasonsteving 3y agoThis section[1] gives a much deeper dive into how I'm thinking about this. [1] https://docs.clarolang.com/generics/contracts/dynamic_dispatch/dynamic_dispatch.generated_docs.html https://docs.clarolang.com/generics/contracts/dynamic_dispat...
- FrustratedMonky 3y agoSo another functional language? I'm all for a hobby projects, this looks good. No disparagement on the effort. But I think the community would be better served if all this brain power could get behind a smaller set of languages. We have hundreds of languages now, none of them are going to get enough market share to ever be adopted.
- systems 3y agoi dont think this one qualify as a functional language, since variables are mutable by default on the second point yes, one the one hand too many languages and too few will see large adoption one the other hand, competition and activity will drive the popular language to continue innovation and not stagnate, look at C# continuously adding functional features, java also to a lower degree while many of those new small languages will never see wide use, their existing is pushing the tides
- jasonsteving 3y agoI just want to echo your point that even though any individual new language is very unlikely to ever see significant use, I would still find deep satisfaction in some of the valuable ideas contained within finding their place in a more mainstream language :).
- 3PS 3y agoSeems like an interesting language with a lot of new ideas, especially the declarative concurrency approach. I am very disappointed by the decision to go with UTF-16 for strings though [0] and strongly urge the author to reconsider. UTF-16 is the worst of all worlds: it is inefficient, it is endianness-dependent, it is still variable-width like UTF-8 for code points outside the basic multilingual plane (like emojis!), and it adds an O(n) penalty to processing most text from the internet. It also means that you need a whole new fundamentally different data type outside of char for encoding byte sequences. Please, for modern software UTF-8 everywhere is the way to go! https://utf8everywhere.org/ https://utf8everywhere.org/ [0] https://docs.clarolang.com/common_programming_concepts/variables_and_types/variables_and_types.generated_docs.html https://docs.clarolang.com/common_programming_concepts/varia...
- egnehots 3y agoit's based on the JVM which uses UTF-16 internally for strings
- 3PS 3y agoUnderstandable, though JVM strings can also use the UTF-8 charset under the hood. In fact, if you initialize a Kotlin string from a byte array, it'll default to assuming the UTF-8 charset [0]. (Kotlin chars are still 16-bit code units though, and it is true that you can't use the native JVM char type if you do this. Personally I think that's still acceptable.) [0] https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-string.html https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-st...
- Pet_Ant 3y ago> Please, for modern software UTF-8 everywhere is the way to go! I think the real answer is to have a String interface and then allow for different implementations. There are times when it should be ASCII 8-bit. Or UCS 4. UCS 2 is reasonable. It's about trade-offs and how much constant width is worth. Just like you can use across different list and set implementations for the algorithmic profiles, you should be able to chose string types. Something UTF8#"Hello World" or EBDIC#"IBM". Inserting, appending etc, a character that cannot fit into a given string should throw an exception.
- purpleidea 3y agoThe DAG concurrency stuff feels familiar to what I've been doing with our language, mcl. https://github.com/purpleidea/mgmt/ https://github.com/purpleidea/mgmt/ Our goal is NOT a general-purpose turing-complete language like this one is, but we do some amazing lock-free, DAG concurrency things to achieve the processing wins.
- purpleidea 3y agoFYI: The code is out there, but AFAICT, the language is not open source. No declared license exists anywhere. So you can't actually use this.
- systems 3y agowell, i dont see any explicit license information, but the source is available on their github repository what does that legally mean, if a project on github share the source publicly, but doesnt state the license, is there like a defacto or default license that applies then
- fwip 3y agoYes, that means it is under copyright, "All Rights Reserved," the same as the latest John Grisham thriller novel. You may look at it, but you may not reproduce it elsewhere or create derivative works (except where covered by exceptions).
- netvl 3y agoInteresting concepts, but dependency on Bazel is meh :( Also, there are some passionate statements about other languages: > As it's currently defined, there's nothing requiring the two arguments to actually have the same type. In this trivial example, that may be fine, but if I were to actually want to ensure that two arguments both implement an interface and they both actually have the same type, then I'm out of luck - there's no way to statically encode this constraint in Java! This is simply not true: static <T extends Stringify> void prettyPrintPair(T x, T y) I personally really dislike when people talk about any kind of language feature with strong negativity, while providing their solution as the superior one. There is a high chance that they are wrong, since different features in the same area have different benefits, and usually no one thing is “better” than another, whatever this means.
- steeve 3y agoTBH, I see the dependency on Bazel as a plus.
- jasonsteving 3y agoSo, I understand why it seems like that Java signature you gave would work, but it in fact does not work. Check out this replit example to see the full example with your signature: https://replit.com/@JasonSteving1/DemoTypeSystemLimitation#src/main/java/Main.java https://replit.com/@JasonSteving1/DemoTypeSystemLimitation#s...
- heresie-dabord 3y ago> As Claro is still firmly in development, it has only been tested on macOS. You may run into trouble running it on another OS as there are some known portability issues building the Claro compiler from source (currently the only supported way to consume the compiler). MacOS only.
- jasonsteving 3y agoHi everyone, I'm the creator of Claro. Thank you for taking the time to take a look into the language! It's been very satisfying and encouraging seeing so many largely positive reactions, it's been a 3 year labor of love (and learning) so I appreciate the feedback. I'll do my best to finally respond to as many comments here that I can get to.