7 ms·
Tamgu, a functional, imperative, logical programming language
- clauderoux 7y agoTAMGU (탐구) is a programming language that combines functional, imperative and logical paradigms into a single formalism. The language has also been specially designed to simplify automatic annotation and data augmentation for Data Programming. Pre-compiled versions for Windows, Mac OS and Linux are available at: https://github.com/naver/tamgu/releases https://github.com/naver/tamgu/releases
- jaehong 7y agotamgu(탐구). intersting. clauderoux, are you from korea?
- clauderoux 7y agoNot exactly, but I work for Naver, which is a Korean company. The lab I work for is in France near Grenoble in the French alps
- 6thaccount2 7y agoI like the idea of having something like PROLOG/minikanren builtin to the language. Prolog is neat, but I wouldn't use it for text processing and database access, so the logic programming piece to me makes better sense as embedded functionality in a more general purpose language, which is what I'm guessing you did here?
- clauderoux 7y agoAbsolutely, you're right. In fact, I first slightly modified the Prolog syntax by replacing the traditional variables that start with a capital letter with variables of the form:"?X". We can therefore differentiate between Tamgu variables and Prolog variables. In addition, Tamgu's basic objects, such as vectors, strings or numbers are automatically reinterpreted as vectors, strings or Prolog numbers. We can therefore apply operations like: [?X|?Z]. Finally, Tamgu considers that the reception variables before the "=" sign define the execution context. Therefore, if we take the following program: parent ("John", "Peter"). parent ("John", "Mary"). parent ("Peter", "Roland"). parent ("Roland", "Pierre"). bool b = parent("John",?X); vector v = parent(?X,?Y); The first case will return "true" if we find a matching occurrence. Here "b==true". The second case will return all the possibilities that match: [parent("John", "Peter"),parent("John", "Mary"),parent("Peter", "Roland"),parent("Roland", "Pierre") Access to each parameter is possible: v[0] = parent ("John", "Peter") v[0][1] == "Peter" v[0].name() == "parent"
- thelazydogsback 7y agoCongrats @clauderoux! -- I've been working on similar fusions on and off during the years. So "?X" is not true logical variable, but more of a part of a pattern expression? -- in other words, a logical var is a first-class object that can be stored in a data-structure (possibly in an unbound state) and be bound at a later time, and perhaps unbound and re-bound again if there is backtracking. So in Tamgu, "parent(?X,?Y)" acts as a one-shot "find" if the LHS is atomic, and acts as a generator (similar to a possibly nested list comprehension) if the LHS is a collection (but no inter-statement backtracking points are established), correct? So is the generation of the sequence eager/realized or lazy/by-need?
- clauderoux 7y agoExactly. If you provide a collection, the system will deduce that you want all solutions to be extracted, while if you provide a non collection variable then it will stop once one solution has been found. Actually, I have a very specific type, which is "predicatevar", if you want to get your unification once. ?X is actually a true Prolog variable that can be unified over and over again. Furtheremore, you can call Tamgu functions from your predicate description, in which these variables can be used if they are unified. grandparent(?X,?Y) :- parent(?X,?Z), println(?Z), parent(?Z,?Y). In the case above, the "println", which is not a predicate, will try to display the content of ?Z, if ?Z has been unified. println could be replaced with a call to an actual function, as long as this function returns true. If the function returns false, then it will be considered as a fail.
- dkersten 7y agoI have the exact same opinion and like minikanren libraries in Scheme and Clojure for that reason. I always liked Prolog, it always felt like an awesome way to write certain aspects of a program, but always felt super awkward for the rest of the program. With this approach, you can write the bits that make sense in the style that most suits. That's a pretty nice thing to be able to do!
- 6thaccount2 7y agoExactly!
- clauderoux 7y agoActually, there is a simple program: hanoi.tmg in https://github.com/naver/tamgu/tree/master/examples/Predicates https://github.com/naver/tamgu/tree/master/examples/Predicat..., which shows how to mix Prolog and imperative programming for a benefit of both.
- chunsj 7y agoLooks like another rewriting of S-expression based logical programming system into non S-expression one.
- dvh 7y ago"20" + 10 = "2010" 10 + "20" = 30
- noobermin 7y ago`+=` a different operator than `+`. `+` is symmetric while `+=` isn't.
- tempguy9999 7y agoDoubtless. But it's one more special case to remember, is it worth it?
- clauderoux 7y agoHello, I guess I should have been more explicit. I'm sorry for the confusion. First, Tamgu is a language in which the recipient variable defines the context in which the instruction is evaluated. If your recipient variable is an integer then everything on the right side of your assignment will be treated as an integer. If it is a string, well everything will be treated as a string. We use this approach in many other instances: int pos; vector v; string s="This is a testing case"; pos = "i" in s; //we are looking for "i" in the string In this case, pos==2. v = "i" in s; //we are looking for all positions of "i" in the string v == [2,5,14]
- tempguy9999 7y agooof. I see what you say about the LHS defining how the RHS is evaluated but that attaches expression evaluation to assignment. You can't do one without the other. Also the target type may be obscure to the programmer. What's the behaviour with string s="This is a testing case"; println("i" in s); But separately your example now looks even worse. It's quite reasonable to expect 'in' to behave the same way for both cases; that they both return [2,5,14] - now you've added another complication. No offence but without some overriding principle, and a justification for that principle (that "things are demonstrably easier if you do it this way"), you've just dumped and extra load on the programmer which I do not need!.
- _bxg1 7y agoQuick point of feedback: the first two imperative (+=) statements presumably are being treated as independent, not part of the same sequence. I.e.: "20" + 10 = "2010" 10 + "20" = 30 This was confusing, given that they are sequential statements listed without any clear separation.
- deleted 7y ago[deleted]
- dkersten 7y agoAutomatic type conversion I think is a mistake. It’s a huge cause for bugs. But even if not, automatic string to number parsing is definitely not something I want in my production code. Not only is it something that causes hard to debug errors, if in a tight loop, it can have big performance impact. There’s a reason modern languages have become stricter on type conversation, instead of less strict. This language looks cool, but I will never use it for this reason.
- noobermin 7y agoI might cause a flame here, but I feel like academics and people who give conference talks have adopted stricter typed languages. Actual developers instead embraced from the get-go rather dynamic languages (Python,Javascript,etc.) and continue to use such languages without the type hints because it's easy and they have things to build.
- em-bee 7y agodynamic languages still have strong typing. the given example of type conversion is one of weak typing. it has nothing to do with strict typing that enforces type declarations. in python this is an error: >>> i = 10 >>> s = "20" >>> s+=i; TypeError: cannot concatenate 'str' and 'int' objects >>> i+=s; TypeError: unsupported operand type(s) for +=: 'int' and 'str'
- willtim 7y agoIt's a nice error message, but it's a runtime error, it might not happen until weeks into production. It's technically just a crash with a useful error message. "strict typing that enforces type declarations" is generally called static typing, and does not necessarily always require annotations or declarations. It spots such errors at compile time using static analysis.
- F-0X 7y ago> it might not happen until weeks into production. It should never happen in production - there should be a test that proves this.
- nudpiedo 7y agoNice set of features and paradigm mix. To which platforms does it deliver it a binaries? Does it deliver binaries or it is compiled, and where does it run the compiled program? Can you show some realistic usage or application and how do all these feature hold together? An mvp todo list could make it, for web or for the command line.
- clauderoux 7y agoHello, I provide binaries for Windows, Mac OS, Fedora, Centos and Ubuntu: https://github.com/naver/tamgu/releases https://github.com/naver/tamgu/releases You also have some examples in: https://github.com/naver/tamgu/tree/master/examples https://github.com/naver/tamgu/tree/master/examples I provide makefiles for all platforms: Windows: Visual 2013 Mac OS: both command line Makefile and Xcode Makefiles (including the native Mac OS GUI) Linux: (also for Mac OS), I provide a python script: install.py that determines what is available on your machine and create a Makefile.in.