Thursday, April 9, 2009

Clean Programming Language: the insanely great, the weird and the short-sighted

If you are reading this blog, chances are you are one of those people who think that Haskell is the most beautiful language ever. Well, you are wrong! Haskell is only the second most beautiful language ever, after Clean (they actually want you to register before downloading, so don't click that link).

The insanely great:
  • Like Haskell, but simpler. Haskell is primarily a research language. Monads, monad transformers, lifts, arrows, templates, bang patterns, etc. etc. get added to GHC on a regular basis. If you want to use Haskell, you'll have to constantly deal with unproven technology in FPL design, like monads and monad transformers. Clean is simpler. If you know Haskell (even if you don't fully grok monad trasformers), you can learn all there is to Clean in a few hours. For better or for worse, the features are pretty stable and simple, which brings us to my second point:
  • No monads necessary. That's right, a lazy functional language that can perform mutation and IO safely without monads. Imagine that! Clean uses uniqueness types in its otherwise Haskell-like type system. This choice turns out to be both easier on the brains and on the optimizer...
  • As fast as C (the compiler is very fast too), and it ain't no bullshit either! You may have heard from Haskell advocates that Haskell is as fast as C. Well, it's really a half-truth. Sometimes, there is simply no substitute for a good old-fashioned array and mutation of it. It's the only data structure known to man that gives you O(1) read, write with a small constant factor to boot. Haskell can give you that, but your choices are: (1) state and other monads (that don't compose too well) with mutable arrays in GHC (that can cause insane GC slow-downs), defeating the purpose of using them or (2) malloc'ed array hacking. If you look at the Shootout entries, Haskell entries are ugly unsafePerformIO and malloc-using hacks with everything stuck into IO monad, where Clean is idiomatic and simple, and still faster!
The weird:
  • 1980s called, they want... If your Clean program encounters a runtime error, like off-by-1 access, it will print a message naming the error and quit. This may have been good enough in the 80s, but these days I expect more finesse. Haskell allows you to handle these situations in a customized way.
  • No FFI. WTF?
  • Have someone who speaks English natively proof-read your books, manuals, etc. I won't go into detail here. I too suck at writing.
The short-sighted:
  • License. For a long time, Clean was closed-source, offering only commercial licenses. A few years ago, Clean was released as open source under LGPL. Can you now write and distribute your closed-source commercial code using Clean? I'm not a lawyer, so I couldn't give you a definitive answer, but in doing so, you would be incorporating part of Clean in your generated binary (statically linked runtime). This might not sit well with LGPL and the Free Software Foundation that may demand that you make your code open-source for doing that.
  • Development model. Clean may be open-source, but it's basically developed in-house. I do believe that programmers should be paid for their time and expertise developing software, especially programmers and brilliant as the authors of Clean must be, but the reality is that programming languages are different from most other software: As a consumer of a programming language, your investment both learning and writing code in it is tremendous. You want to be assured that your language will continue to exist in the future and won't cost an arm and a leg later. You simply won't use a language for anything important, unless you get these assurances. That's why, unless your vendor is a predictable monster like MS, for a programming language to be viable it has to either have open standards and multiple vendors, or have a fully open and distributed development and place no restrictions on the runtime (generated binaries) whatsoever. I want to ask Clean authors: is it better to have 5 users of whom 0 or 1 are paying customers or to have thousands of non-paying users, who however might make you famous and buy your books?
Conclusion:

If you are developing performance-demanding code and love FP, Clean may be a very good choice for you, assuming that you don't shy away from LGPL and can live with some eccentricities like missing FFI and 80's style error messages.

19 comments:

  1. The LGPL is specifically designed to allow code licensed under it to be linked together with code not licensed under it. Originally it was called the "library GPL" for exactly this reason.

    ReplyDelete
  2. @ habitue01

    Iffy for STATICALLY linking LGPL-licensed code into closed-source software.

    ReplyDelete
  3. fpmatters,

    http://en.wikipedia.org/wiki/LGPL :

    Essentially, it must be possible for the software to be linked with a newer version of the LGPL-covered program. The most commonly used method for doing so is to use "a suitable shared library mechanism for linking". Alternatively, a statically linked library is allowed if either source code or linkable object files are provided.

    It wasn't hard to find. Please don't fud. thx

    ReplyDelete
  4. Monads are certainly as well-tested as Clean's uniqueness typing -- there is nothing unproven about them.

    ReplyDelete
  5. "Alternatively, a statically linked library is allowed if either source code or linkable object files are provided."

    That's what the OP meant by "iffy", though perhaps he should have provided the link. LGPL can have serious issues for instance in the case of embedded systems where tools like linkers are proprietary and cost big bucks.

    His point stands that almost all well-considered languages deal with this issue by providing a more permissive, MIT/BSD style license, at least for the linked runtimes. Even GCC uses a modified license rather than straight GPL/LGPL to cover this case.

    ReplyDelete
  6. "LGPL can have serious issues for instance in the case of embedded systems where tools like linkers are proprietary and cost big bucks."

    Huh? The LGPL doesn't say anything about the cost of the tools, only that the linkable object files must be provided. You don't have to provide a toolchain, that's an exercise that's left to the reader.

    And it's not an untenable situation either. The ATI and NVidia Linux kernel drivers are shipped as object files, for instance. They don't do it because of the LGPL, but the point is that it's completely doable.

    All that said, yes, it would be nicer/more thoughtful to provide the runtime under a less restrictive license, like *every other compiler in the world*.

    ReplyDelete
  7. If you don't like a LGPL license, you can buy a commercial one for Clean.

    ReplyDelete
  8. It actually does have some sort of FFI, but it doesn't seem to be documented. There's a limited binding with OpenGL, for example, but I haven't looked into it much to see how it works. Seems like a really nice language, I gave up on Haskell in frustration, it has some great features but programming in my spare time shouldn't be that hard. Clean looks like it would be a good alternative, but it doesn't have the same community that Haskell does, sadly.

    ReplyDelete
  9. Are you desperately in need of a hacker in any area of your life???

    then you can contact: wizardcyprushacker@gmail.com

    I will help you at affordable prices, i offer services like
    -hack into your cheating partner's phone(whatsapp,bbm.gmail,icloud,facebook and others)
    -Sales of Blank ATM cards.

    -hack into email accounts and trace email location -all social media accounts,

    -school database to clear or change grades,

    -Retrieval of lost file/documents

    -DUIs -company records and systems,

    -Bank accounts,Paypal accounts -Credit cards hacker

    -Credit score hack -Monitor any phone and email address

    -Websites hacking, pentesting.

    -IP addresses and people tracking.

    -Hacking courses and classes.

    my services are the best on the market and 100% security and discreet work is guaranteed.,...

    ReplyDelete
  10. Tired of getting scammed by fraudulant hackers? HC can help you with any needs from security, to spying on a cheater, to changing grades, helping with credit issues, hacking any social media, and more contact proethicalhelp@protonmail.com today for prices and assistance. These people helped me out when I really needed it so I guarantee their work. Email at proethicalhelp@protonmail.com

    ReplyDelete
  11. Gaining access into my wife’s device was not that easy, as my expertise wasn’t that much not until I told AFONKAPETROV@TUTANOTA.COM about this. He helped in cracking the AES (Advanced Encryption Standard) and EXPLOITING all VULNERABILITIES in the device hereby providing a thorough access to the mobile’s data. After all, it was not a waste of effort. There was SEVERE INFIDELITY on her part. Now, I guess I need the divorce immediately and child custody too.

    ReplyDelete
  12. If you really need a professional hacker to hack your cheating boyfriend's/girlfriend's/spouse phone, whatsapp, facebook, bank account hack etc. Or credit score upgrade, I would recommend
    ETHICALHACKERS009@GMAIL.COM
    He has proven to be trustworthy, His jobs are fast and affordable. He has carried out over 3 jobs for me including helping me hack my ex wife's mobile phone and i can't forget when he cleared my credit card debts and improved my credit score to 750. I can put my money on him at anytime!. He's one of the best out there. Spreading the word as my little favor to him for all he's done. Thank me later.

    ReplyDelete
  13. I had a fruitless search for a lover, all F.A.K.E acquaintances. I even lost a bit above 39,400 EURO. My worst experience, but I didn’t let him go with this. I had reported this case to AFONKAPETROV@ TUTANOTA. COM . I was able to recover funds he stole from me as a result of AFONKA’S ADVANCED PENETRATION into HIS MOBILE PHONE LINKED TO HIS BANK, SNIFFED HIS MAILS AND WAS ABLE TO H.A.C.K INTO HIS BITCOIN WALLETS. We gained more than I lost and shared BTC with AFONKA. I am so delighted, even donated to charity. I don’t think I’ll try to find love online ever again. It wasn’t a good experience.

    ReplyDelete
  14. MY NIECE HAD ISSUES IN COLLEGE and needed some grades upgraded discreetly, I was directed to contact AFONKAPETROV@ TUTANOTA. COM This was a major breakthrough for us from her failure. The reason behind this was due to s.e.x.u.a.l a.s.s.a.u.l.t.s by the College Professor. This instigated failure for my niece. We had reported the case earlier and nothing was done. Anyway, her grades were successfully changed.

    ReplyDelete
  15. hello i just want to bring to your notice an easy way of becoming a millionaire.I read about a blank ATM card & decided to reach out to this vendor, he then gave me the guidelines & proof of how the card was cloned. Though i wasn’t sure about their services but they assured me of safe & geniue transaction if i obliged to their terms and conditions which i eventually agreed to & 4days later i was delivered a card by the Delivery service which was sent from this hacker. I was shocked when the card dispensed $2000 instant, I've been able to cash out $10k...All thanks to you guys, you can email this real and reliable hacker via email: (verifiedhackinghome.hackers@gmail.com) or whatapp +1(516) 494 0313.

    ReplyDelete
  16. CONTACT US FOR ALL KINDS OF HACKING JOB @ onairhacker@aol.com We offer professional hacking services , we offer the following services;
    -University grades changing
    -Bank accounts hack
    -Erase criminal records hack
    -Facebook hack
    -Twitters hack
    -email accounts hack
    -Grade Changes hack
    -Website crashed hack
    -server crashed hack
    -Skype hack
    -Databases hack
    -Word Press Blogs hack
    -Individual computers hack
    -Control devices remotely hack
    -Burner Numbers hack
    -Verified Paypal Accounts hack
    -Any social media account hack
    -Android & iPhone Hack
    -Text message interception hack
    -email interception hack
    -Untraceable Ip etc.
    Contact us at onairhacker@aol.com or text or call (+1 617) 340-5668 for more inquiry..
    Track Calls log and Spy Call Recording.
    Monitoring SMS text messages remotely.
    Cell phone GPS location tracking. Spy on Whatsapp Messages.
    Free Update and 100% Undetectable.
    Track BBM messages and Line messages.
    View All Photos Captured.
    Track Internet Browsing History and Read phone Access Address Book, totally worth your money, please no time wasters, he won't under any circumstances work for free, you can reach him by email onairhacker@aol.com or text, call (+1 617) 340-5668

    ReplyDelete
  17. I believe it was impossible to alter grades on a university database. I was in desperate need of a grade reconstruction. I was in dire need of an hacker with incredible penetration abilities. I stumbled on THE_PRIEST@TUTANOTA.COM who had tremendous reviews of successful grade re-constructions without a detection from the school's security. I put my faith in The Priest. I was anxious and worried through the 72 hours of the project. It has been over a month now and my grades are great and there's been no detection. I owe it to you THE_PRIEST@TUTANOTA.COM you are my hero!!

    ReplyDelete
  18. Anon: I was tired of being frugal because it made me lose focus. Now, I am better investing and getting advices from SENIORCITIZENINVEST. C O M on making the right choices for a stable present and future. My wife has been really impressed. We are happier and earning even way more now.

    ReplyDelete
  19. It is a shame how people come in contact with fake hackers, I was a victim too until I met Wizard Schwartz Hacker. He helped me when I needed him the most. His charges are so minimal I decided to help promote him. Some of the services he renders include the following:

    ++ Boost your credit score
    ++ Identify & Track fake hackers
    ++ Recover funds from fake hackers.
    ++ Social media account hack
    ++ Game hack
    ++ Website and database hack
    ++ Erasure of criminal record
    ++ Bank account hack
    ++ Track a cheating mate/hack their phones
    ++ Software cracking
    ++ Grade system hack
    ++ Bitcoin mining and recovery and lots more. He is the best in what he does.

    CONTACT HIM : schwartzsoftwarehackingprogram@gmail.com, WhatsApp:+1 704-313-9661

    ReplyDelete