8 ms·
The Mercury programming language
- thrwia22 8y agofaq in the documentation is mostly useless. but the wikipedia entry on it is quite succinct and good. but still after reading that wikipedia article and skimming through the website, i, as a typical average code monkey with a some grasp of python/js/whateva else among these lines, have no clear idea what and where mercurylang is useful for. can someone eli5-explain that to me in a few sentences?
- aidenn0 8y agoThe e-mail client I use (bower) is written in mercury.
- colanderman 8y agoMercury is the love child of Haskell and Prolog: that is, a very strongly typed logic language. However, it's not quite as flexible a logic language as Prolog (owing mostly to its strong typechecking and modality system), so in practice it's closer to a Haskell with a different I/O containment mechanism (uniqueness types instead of monads) and the ability to sometimes write reversible functions if you bang your head against the modality system hard enough. Its compiler is impressive, and is capable of acts such as compiling certain non-tail-recursive functions in a tail-recursive manner, or even transforming them into tail-recursive equivalents, given the right hints. All this capability comes at a cost. At least as of ~4 years ago, the error messages the compiler can spit out over modality errors dwarf even those from C++ templates. And compiler bugs/unimplemented features are not unheard of.
- astrange 8y agoI want to point out that Mercury is an eager language, so it's more like ML than Haskell. It does have the ability to backtrack and execute in reverse, which is kind of magical in the way people think Haskell is. I wanted to learn it recently, but couldn't find enough example programs.
- toolslive 8y agoYes, uniquenes types for IO (with proper syntactic sugar) really felt powerful, elegant and correct all at the same time.
- bjz_ 8y agoAs Mike says in a sibling comment, we use it quite heavily for implementing our HTML-to-PDF browser engine, https://www.princexml.com https://www.princexml.com It's a pretty handy general purpose language, kind of a combination of Prolog and Haskell. It's much easier to maintain a long-lived project in Mercury than one in Prolog due to the static typing, and it also generates much more efficient code. That said, it doesn't have the greatest documentation, so you might have to reach out on IRC, or the mailing list if you run into some challenges with it.
- dundunduuuuun 8y agoI agree with bjz_ - the documentation isn't great, and may have deterred more than a few curious individuals. That aside, it's a pretty nifty language and I found learning it worthwhile.
- mikeday 8y agoWe use Mercury at YesLogic to write Prince, our HTML to PDF formatter! [1] We chose it because logic/functional languages are great for tree processing, Mercury was designed for large projects, and because in 2002 there really weren't many other options around. Its syntax and semantics are derived from Prolog, it borrows a lot from Haskell (types, type classes), in spirit it's reminiscent of OCaml (niche, little weird) and with support for unique modes there is some interesting overlap with Rust, although this aspect of the language still needs more compiler support. All in all, definitely worth checking out. [1] https://www.princexml.com/ https://www.princexml.com/
- marmaduke 8y agoThe Java class caught my eye. Is that a wrapper around a native lib or you make RPC calls to something? HTML to PDF is something I never thought about since Firefox does it (and results usually aren’t great).
- mikeday 8y agoIt's a wrapper around the native process just to simplify passing command-line arguments. (There is also a persistent process mode for speeding up batch processing of many small documents). The browsers don't specialise in PDF generation, and we do :)
- mpweiher 8y agoI've seen a bunch of these (HTML -> PDF). I've never seen a succinct answer to: "How is this different/better than taking <random web browser> and hitting "print", which at least on OS X will produce a nice PDF?"
- lillesvin 8y agoI'm not the guy you asked but I've been using PrinceXML to produce PDFs intended for customers of our client (e.g. invoices, terms and conditions, itineraries, etc.). Sure, we could just display the HTML and let either the customer or the sales agent press "Print to PDF" but it's not very user friendly—non-power users may not know that "print to PDF" is even an option—nor is it particularly practical for batch processing. Full disclosure: If I'd had my way we would have used LaTeX templates to produce the PDFs but the previous developers had already implemented the HTML->PDF flow, so we just replaced the old, defunct service with Prince, which did a surprisingly good job, IMO.
- mproud 8y agoFairly certain I looked at this back in 2004 while I was in college. I don’t remember too much, but my prof. thought it was cool.
- jlturner 8y agoI’ve written quite a bit of Mercury for fun, and I think it’s a great language. It feels more like writing in a statically-typed functional language (like OCaml) than a logic language like Prolog, despite the syntax and presence of relations. I’d love to see more people and companies adopt it; it’s a shame how important technology popularity is for most companies.
- fithisux 8y agoIt had caught my eye but never used it. What kind of problems can I use it for?
- marcosdumay 8y agoMercury is great at basically the same problems you would solve with Prolog, but has added purity markers that help your code not have exponential slowdowns caused by hard to discover bugs.
- YeGoblynQueenne 8y agoIt's a Turing complete programming language. There are, literally, no programs you can't write in it.
- jlturner 8y agoAnything, web servers, systems programming, video games, etc. Its more of a different way of programming and thinking, using logic variables and unification to solve problems. Once you wrap your head around logic programming, its pretty easy and very powerful. Mercury's selling poings are: - runtime performance (automatic parallelization, very efficient due to logic programming understanding and rewriting sequenced operations) - static typing (in an ml style / like OCaml) - logic programming (unification of lvars) As a language it fills an interesting niche as logic progamming language typically aren't dyanmically typed or high performance (ie Prolog, most miniKanren implementations). Paul Bone has some good talks on Mercury if youre interested (heres some slides from an intro talk to Mercury https://paul.bone.id.au/pub/pbone-2015-mercury.pdf https://paul.bone.id.au/pub/pbone-2015-mercury.pdf)
- dotdi 8y agoWhenever a language pops up on HN I excitedly look at it. Unfortunately, the documentation, FAQ and User Guide all failed in succinctly giving me the information I need: what can it do well, what does a known snippet look like implemented in <Lang>, how does it compare to other languages, etc. I appreciate the fact that the documentation seems extensive and well-structured, but that is only helpful to persons who already know they are going to use the language (i.e. University Students in Melbourne?).
- z3t4 8y agoYou can't simply judge a new language by looking at it's surface, as there are not only different languages, there are different coding styles. And then there's probably frame-works on top. So it's very unlikely that the examples will be in the style you would prefer. I think the only way to judge a language is to use it full time for at least one year, but even then you will probably just have scratched the surface. Unless you care for things that can be measured, like speed and performance. Which in case you could probably bend and twist most languages using transpilers or meta - to suit your preferred style.
- bjz_ 8y agoMarketing and good communication design is important though, if you want to actually reach new users. If somebody can't get the gist of what you're about from a glance, they are far less likely to invest a year into giving it a solid try.
- mmmeff 8y agoExactly. I agree, not because of vanity, but because if a language fails to market itself well, it's probably not going to succeed in becoming adopted, and adoption breeds support in the form of open source libraries and job prospects. Most devs don't have the time to pick up esoteric hobbyist languages because they're clever.
- fnordsensei 8y agoAdditionally, ALL marketing/landing pages should back up their claims with evidence. It doesn't have to be much, but there's definitely bonus points where a short motivation is provided with links to further reading. It doesn't have to be hard evidence exactly, but if you're claiming that something is easy, fast, "modern", what makes it so? I concede that you can get away with it to some extent by splicing in "intended to be" in the sentence, but it still places on the visitor the burden of figuring out the "why" behind the marketing.
- nraynaud 8y agoI learned so much reading the papers on this website 15-20 years ago: https://www.mercurylang.org/documentation/papers.html https://www.mercurylang.org/documentation/papers.html
- hlieberman 8y ago> In the past when working with improper window management I have found that reaching for the rodent and lifting my eyes off my FSF emacs block cursor can trigger undesired distractions, particularly when I'm working in non-Lisp dialects (well except for mercury and Pop-11) because any idle brain wave will be spent bitching to yourself silently about the lameness of the artificial language you are forced to be thinking in presently. - SCWM, Pot and the GPL (the Ratpoison Manifesto)
- skrebbel 8y ago> In spite of its lack of popularity, LISP (now "Lisp" or sometimes "Arc") remains an influential language in "key algorithmic techniques such as recursion and condescension" - A Brief, Incomplete, and Mostly Wrong History of Programming Languages
- YeGoblynQueenne 8y agoThat's very funny - why don't you post it on HN?
- aidenn0 8y agohttps://news.ycombinator.com/item?id=11936058 https://news.ycombinator.com/item?id=11936058 https://news.ycombinator.com/item?id=5695816 https://news.ycombinator.com/item?id=5695816 https://news.ycombinator.com/item?id=1475826 https://news.ycombinator.com/item?id=1475826 https://news.ycombinator.com/item?id=16695995 https://news.ycombinator.com/item?id=16695995 https://news.ycombinator.com/item?id=16353070 https://news.ycombinator.com/item?id=16353070 https://news.ycombinator.com/item?id=17741163 https://news.ycombinator.com/item?id=17741163 https://news.ycombinator.com/item?id=6953863 https://news.ycombinator.com/item?id=6953863 https://news.ycombinator.com/item?id=17400757 https://news.ycombinator.com/item?id=17400757 https://news.ycombinator.com/item?id=6504217 https://news.ycombinator.com/item?id=6504217 https://news.ycombinator.com/item?id=5728843 https://news.ycombinator.com/item?id=5728843 https://news.ycombinator.com/item?id=12443815 https://news.ycombinator.com/item?id=12443815 https://news.ycombinator.com/item?id=1310127 https://news.ycombinator.com/item?id=1310127 https://news.ycombinator.com/item?id=599164 https://news.ycombinator.com/item?id=599164 https://news.ycombinator.com/item?id=1327746 https://news.ycombinator.com/item?id=1327746 https://news.ycombinator.com/item?id=3503896 https://news.ycombinator.com/item?id=3503896 https://news.ycombinator.com/item?id=16933760 https://news.ycombinator.com/item?id=16933760 https://news.ycombinator.com/item?id=8659818 https://news.ycombinator.com/item?id=8659818
- dang 8y agoDiscussed in 2010: https://news.ycombinator.com/item?id=1896219 https://news.ycombinator.com/item?id=1896219
- packetpirate 8y agoMaybe I'm just lazy, but from a quick glance, this language seems a little too wordy for my tastes... why "import_module" instead of just "import"? Or "write_string" instead of "write"? I prefer a terse programming language that uses more descriptive keywords in favor of more of them. But I suppose that's not really the most important factor of a language and the syntax could be fun to try out.
- astrange 8y agoPutting types in the keywords is sensible if you don't have multimethods/generic functions. I don't remember if Mercury has those or not.
- gmfawcett 8y agoI happen to co-moderate a tiny little subreddit about Mercury: https://www.reddit.com/r/mercury/ https://www.reddit.com/r/mercury/ . It has a few links to blog articles with examples, slide decks, etc. New members are more than welcome! Mercury is an interesting language, and it would be nice to bring enthusiasts a bit closer together.
- roller 8y agoOne interesting aspect of mercury is the number of available back-ends (grades) [1]. I'm curious if anyone has any experience using the FFI [2] for embedding mercury into a larger Java, C# or Erlang project. [1]: https://www.mercurylang.org/about/backends.html https://www.mercurylang.org/about/backends.html [2]: https://mercurylang.org/information/doc-release/mercury_ref/Foreign-language-interface.html#Foreign-language-interface https://mercurylang.org/information/doc-release/mercury_ref/...
- equalunique 8y agoVery cool to see another active project that draws upon Prolog for inspiration. > The benchmarks were run on a Sun SPARCserver 1000 with four 50 MHz TI SuperSPARC processors and 256 megabytes of memory running SunOS 5.3 (Solaris 2.3). Each processor is rated at 60.3 SPECint92, and has a 4-way associative 16 Kb I-cache and a 5-way associative 20 Kb D-cache, backed by 1 Mb of unified secondary cache. What's the rationale behind such antiquated benchmarking system? Interesting.
- mikevin 8y agoCould it be designed to limit variance and the impact of clever hardware and its unpredictable nature? I can imagine benchmarking on a new high-end desktop machine would require a lot of work to make sure your benchmark isn't impacted because you ran it Friday at 11:44 and the cron job that runs at 11:45 messed up a few key caches, made your CPU heat up that extra 1 degree celcius causing some throttling to kick in, causing your prng to be seeded with a value that triggers a few worst-case performance scenarios etc. There are a lot of factors that can influence a modern system and most of them seem hard to control. For a 8086 you could probably account for all these factors if you put in the hours and run it in a highly controlled environment but I doubt its even possible for a modern CPU, let alone the whole system. Of course this isn't a problem for most benchmarks as most of them are only useful for demonstrating real world use-cases where the variance is expected and the goal is not to benchmark the performance of a single element of the system but the perceived performance you can expect in a real-world scenario. Or its simply designed by someone who loves this kind of system and found a good excuse to put one to use.
- rurban 8y agoMaybe a (1998) subject tag would be in order here, that's when the current web page went up. The language is much older though. Quite influential in those times ("typed prolog" with a better compiler), but didn't gain that much attention and some mercury projects were rewritten then in other languages.