Clean – A functional programming language
clean.cs.ru.nl
clean.cs.ru.nl
I get that people have syntax preferences and that there's a certain level of "sniff" test that goes along with these things, but as a fan of programming languages I am always interested in the semantics. That is, I'm interested in what's different about this language and its combination of features and goals:
http://clean.cs.ru.nl/Language_features
> The uniqueness typing system of Clean makes it possible to develop efficient applications. In particular, it allows a refined control over the single-threaded use of objects which can influence the time and space behavior of programs. Uniqueness typing can also be used to incorporate destructive updates of objects within a pure functional framework. It allows destructive transformation of state information and enables efficient interfacing to the nonfunctional world (to C but also to I/O systems like X-Windows) offering direct access to file systems and operating systems.
When I read that I think, "Wow! That seems really neat and reminds me of linear types, and I should check this out". Maybe that's just me though.
It's also worth noting that the features page does not mention the word syntax. That's not a deep insight or strong evidence for anything really but it suggests that the designer was interested in the semantics too and that the syntax was a secondary concern.
"I get that people have syntax preferences and that there's a certain level of "sniff" test that goes along with these things, but as a fan of programming languages I am always interested in the semantics."
Well, as the syntax commenter, perhaps I'm a bit defensive but I feel like syntax is inherently an important part of what makes a language appealing - features aren't enough. To take it further, I'm pretty sure if you only absolutely only wanted features for manipulating things, you could find those features in some C++ or Java library. Just the Boost library is vast beyond my ability to encompass it but I'd prefer not to be manipulating hundred-line spews of angle-brackets and stuff.
And I, too, like programming language and I feel what makes a language as such cool/useful/etc is that you express a computer's action in a compact, elegant and clear fashion for one's fellow human beings. I remember Steve McConnell said something like "the compiler only has to read source code once but your fellow programmers will need to read it thousands of times".
...it suggests that the designer was interested in the semantics too and that the syntax was a secondary concern
Well, the problem is semantics is part of the user experience regardless of the developers intent. If anything, whenever X is important but X is not a concern of the developers, the chances of X biting you go up, not down.
> To take it further, I'm pretty sure if you only absolutely only wanted features for manipulating things
I feel like lisp fits this bill to some degree. Being the AST itself it is "without syntax" to some degree. I wonder if you dislike Lisps? I can't really tell you what this means with regards to our discussion I'm just curious.
> And I, too, like programming language and I feel what makes a language as such cool/useful/etc is that you express a computer's action in a compact, elegant and clear fashion for one's fellow human beings.
Definitely! I would never suggest that we should entirely ignore how the syntax affects our ability to read the code but, to borrow the lisp example again, I don't care about typing lots of parenthesis if I'm otherwise effective.
Again, your earlier comment is not unfounded and I appreciate where you are coming from.
I'll admit my professional work has been limited to C++, python, Ruby, PL/SQL, Matlab and small DSLs. I've played lisp and the-fp-languages in college. Lisp and the-fp-language both seemed to at least have clean, simple syntax rules.
I started using Ruby both it was hip and because it's free form syntax was really fun. If there were languages I definitely to learn, I would be less critical about syntax and style.
My original comment on Clean's syntax wasn't intended as a full judgment on the language but simply a reaction, a reaction I shared because it seems like subjective impressions of syntax matter for the reasons I mention above.
fac :: Int -> Int
fac 0 = 1
fac n = n * fac (n-1)
to me, is that all the statements of this function declaration seem "disconnected". I'm guessing the "fac" connects them but it seems less clear than open-closed brackets in a c-like language (and also more cluttered). Especially, I'm not sure what tells me I've reached the end of the function declaration. This may seem trivial but it's always put my off this variety of functional language.I do understand your argument and tend to agree, I would like to see a syntax error if there is anything between the multiple lines of implementation.
I think it’s just a matter of familiarity. Once you learn how it works, it’s actually extremely elegant and in no way “disconnected.”
So this says three true things we know about this 'fac'
Firstly it says it takes an int and it returns an int.
Secondly that if the int it takes is specifically zero then the int it returns is specifically one.
Thirdly and lastly, for all other ints it returns that int, times (in the arithmetic sense) a recursive call to itself of the int one less.
I worry about why it doesn't have to say abs(n) but then I remember two negatives multiplied together are positive.
The function doesn't terminate if n is negative, so you are right to worry!
fac :: Int -> Int
(0) => 1
(n) => n * fac (n-1)OP's first four words: "The thing about syntax".
The differences may be miniscule. They are syntactic. "Might be cool to" have this other syntax. You're just belaboring the obvious.
fac :: Int -> Int
fac x = case x of
0 -> 1
n -> n * fac (n-1)
or even {-# LANGUAGE LambdaCase #-}
fac :: Int -> Int
fac = \case
0 -> 1
n -> n * fac (n-1) fac :: Int -> Int
fac(0) => 1
fac(n) => n * fac(n-1)also, this is syntactic sugar for a case statement.. and you couldn't just use those.
In Haskell you could always avoid that style and use the case syntax (or for this example guard syntax) instead. All varieties eventually desugar to a case analysis anyway. Haskell even added curly braces as an alternate to indentation!
If clean has a REPL (which I couldn’t easily find out from its web page) I expect it to have that, too.
In the Haskell REPL, you would need to enter the definitions together.
Conflating of data types with storage types is a surprisingly common occurrence, although I can appreciate it's largely due to pragmatism.
Point being, you're spot on about mixing types and even "simple" functions need not be trivial (for various reasons, eg: factorial of a negative number - might be defined as negative infinity):
Everything is way more "disconnected" in OOP. For example I have to implement length in both the classes EmptyElement (0) and Element (1+next->length()). Both belong together, but they are scattered across the source code. With clean like syntax i would have written them right next to each other.
I had started with F# and was put off by it like you described. I moved to Haskell and had difficulty understanding it yet again, but when I moved back to F# one more time it was a delight.
Also, I've come to appreciate when I write in say Rust, the fact that I can let go of the syntax, just write and focus on my ideas and let my editor sort the mess at the end.
I still like languages like Python and F# though.
Having types and removing statements from the language make this much less of an issue
> I can let go of the syntax, just write and focus on my ideas and let my editor sort the mess at the end.
Elm has a whitespace significant syntax, but it too has an excellent code formatter tool.
About style, after a while spent reading about FP, I just can't solve problems without it.
Most of my code quickly ends up in lines of
// f <param-1 subset> <param-2 subset> => desired structure //// type
// f <param-1 subset'> <param-2 subset'> => desired structure //// type
which then gets translated on whatever language I end up writing (javascript, java, emacs lisp ..)I've read it's the lack of community. The name doesn't help either.
"Developers wishing to distribute commercial applications (either publicly or privately) can purchase a commercial license."
Although there seams to be a dual license now? Can anybody with more understanding of legal verbiage confirm that if I choose to use the bsd+lgpl then the above restriction don't hold anymore?
> The company is not claiming that you can't sell your programs. The licensing only matters when it comes to modifying the compiler itself.
which it makes sense. The language runtime is LGPL but the program you write is anything you want.
At http://clean.cs.ru.nl/download/Clean24/CleanLicenseCondition...
> Clean is available under a dual license. Users can choose which of these two licenses they wish to operate under:
> 1 The Simplified BSD License (see below) applies to the libraries, runtime system and examples, the LGPL the standard GNU Lesser General Open Source license (see below) to the rest. The libraries, runtime system and examples consist of the files in the following directories (including subdirectories of these directories):
> - Libraries and Examples (versions for Windows)
> - StdEnv, data and examples (versions for Linux and Mac OS X)
> - libraries, RuntimeSystem and CleanExamples (source code).
> 2 A commercial license (see below) that can be purchased. Information on that license can be obtained from [check the original document for name and email]
So, it should be ok as using any LGPL library on any proprietary program. I wonder if they are making any money from the commercial license or this confusion is only harming the language.
So it sounds about right to me.
Example, Clean programs working fine on Linux --
https://web.archive.org/web/20130101063215/http://benchmarks...
In my experience with Clean, uniqueness typing has been some kind of magic.
Clean had a performant compiler when Haskell was mostly interpreted and slow. Why didn't it take off? Maybe it wasn't the main goal of its developers once the publications were done.
edit: to note that by 'written' i mean designed and initially implemented.
I believe a large part of Rust's popularity is due to its superb library infrastructure via Cargo and crates.io. Furthermore, I believe a large part of its contemporary competition (say, go, swift and crystal) tripping on its own feet is the lack (or weaknesses) of such a thing.
afaict there was a moment when most of the "pure" "lazy by default" functional language projects coalesced into Haskell to build working mass -- except the developers of Clean continued to see value in strictness analysis and uniqueness typing but that limited the numbers developing libraries and tools.