Live data from Hacker News

Show HN: KatLang – Language for Calculations

katlang.org

21–30 of 46 posts

Re: Show HN: KatLang – Language for Calculations

#21

Looks good. Curious about the syntax of function declaration - i.e.: A = x * y + x And then I invoke it by: A(2, 3) Implicitly using the order of which the parameters were used in the function declaration. Rather than having it explict either via: A = (x, y) => x * y + x Or via named parameters: A(x = 2, y = 3) Why this design?

Without trying to speak to why "katlang" does what it does, there are other languages that do this and I can speak to how useful it is when you already prefer functions of low arity: It repeatedly demonstrates a substantial improvement in bug/defect reduction and code.

APL does this; a function like {ω×α+ω} and assigns omega to the right-argument, and alpha to the left-argument. They also have ωω for the right-side function and αα for the left-hand function for writing higher-order functions. Dyadic expressions tend to modify their right-hand argument, and not the left, so for the times that the arguments are "backwards" this can usually be fixed with the commute operator (⍨) which looks similar to katlang's "grace" operator (~) so I assume at least some influence.

k/q does something more similar: a function like {x*y+x} assigns the first argument to x, the second to y, the third to z. The author seems inspired by this behaviour (even mentioning it in a linked paper). In q, when the function is in the q context, x is the left-argument and y is the right-argument when called dyadically. Sadly, q and k don't have commute.

Re: Show HN: KatLang – Language for Calculations

#22

Earlier quoted context omitted.

Modern math syntax is relatively new, it started to form in 18th century. It is not too late to make some changes. Implicit parameters is only one feature in KatLang. Classic math functions can return only one value, that is why in KatLang there are no functions. In KatLang everything is an algorithm - concept which can return several outputs. Yes, some programming languages have syntactic sugar for that too, but sti…

Few programming languages actually support returning multiple values, and those that do are I think all quite old: the usual course these days is just to support record or tuple/list types and some kind of destructuring syntax, with the completely incidental effect of simulating returning multiple values, typically without any syntax sugar (unless you count destructuring, which is normally strictly sugar, but it’s of…

Tuples require object deconstruction syntax. KatLang does not have object deconstruction feature. KatLang has simply deconstructed the function into input and output. In KatLang you define algorithms by specifying inputs and outputs. If You use implicit parameter, then the algorithm has an input. If You do not use implicit parameters, then the algorithm has only output and it is more like a data structure rather than a function.

I agree, that parameter ignorance operator # is ugly. I do not like it. The plan is to remove it in the future versions, but it requires some research.

About expression reading and parsing... Your argument is correct, but KatLang expressions are relatively short. I do not expect that KatLang will replace general purpose programming languages. KatLang is just a simple language for calculations. Main goal was to redesign the calculator and KatLang is good for that.

Re: Show HN: KatLang – Language for Calculations

#23

Earlier quoted context omitted.

Few programming languages actually support returning multiple values, and those that do are I think all quite old: the usual course these days is just to support record or tuple/list types and some kind of destructuring syntax, with the completely incidental effect of simulating returning multiple values, typically without any syntax sugar (unless you count destructuring, which is normally strictly sugar, but it’s of…

Tuples require object deconstruction syntax. KatLang does not have object deconstruction feature. KatLang has simply deconstructed the function into input and output. In KatLang you define algorithms by specifying inputs and outputs. If You use implicit parameter, then the algorithm has an input. If You do not use implicit parameters, then the algorithm has only output and it is more like a data structure rather than…

Minor technical correction: tuples don’t require deconstruction syntax; x[0] takes the first element of a tuple in Python, and x.0 in Rust (though it is fun to note that Rust only got that in late 2014, before which pattern matching was the only way of pulling values out of a tuple).

For the rest, I maintain my position. :-)

Re: Show HN: KatLang – Language for Calculations

#24
post #19

Earlier quoted context omitted.

I was obsessed with the perfect syntax. Declaring method parameters in method parameters list is redundant, because the parameters appear in the method body anyway. This approach is not the best in all situations, but for short expressions, like lambda expressions, it is perfect (in my opinion). Check my paper on comparing lambda expression implementation: https://www.bjmc.lu.lv/fileadmin/user_upload/lu_portal/proje.…

There's at least one type of lambda missing from your paper, the OCaml function. After using the keyword `function`, you can directly go into a match: let toto = function | 0 -> 'a' | _ -> 'b' About the contents of the paper, I'm not sure that I agree with you. There is a clear distinction between lambdas with shorthands and lambdas with named parameters, and I think it exists for a good reason. You seem to base your…

Your OCaml function example looks like feature I call conditional parameters in KatLang (inspired from Erlang). In mathematics exists many different concepts which are called perfect. For example, perfect numbers. God called Lucifer a perfect. I provided a definition for symbols perfectness and tokens perfectness. You can call it unprofessional, but I did my best. I do not call my work perfect to make it more significant. I use term perfect as an attribute of the code expressions. Imagine identity function:

  function(x) {return x; }
In KatLang You can define it as:

  x
The question is: can you remove one more symbol without changing the meaning of the expression? If no, then, the identity function definition 'x' is symbols perfect according to my definition. Of course, I rely on the usage context and it allows me to hide some part of critical information and focus only on the short lambda expression.

Thanks for the elixir examples.

Re: Show HN: KatLang – Language for Calculations

#25

The author here. I am ready to answer any questions about KatLang. The future plan is to create android app and I hope that it will become the future calculator. I have been postponing android app creation for years, but now KatLang is in good shape and I can continue with tool development.

I'd enjoy a page that explains why I should care. What makes it special?

I think, that there is needed Android app - calculator using KatLang syntax. That (or maybe iOS version) would make You care about it. I am planning to use KatLang syntax for physics tests in schools. Physics formulas can be defined using KatLang syntax. That is experimental idea, but I believe, that it can make a difference.

Re: Show HN: KatLang – Language for Calculations

#26

Earlier quoted context omitted.

Tuples require object deconstruction syntax. KatLang does not have object deconstruction feature. KatLang has simply deconstructed the function into input and output. In KatLang you define algorithms by specifying inputs and outputs. If You use implicit parameter, then the algorithm has an input. If You do not use implicit parameters, then the algorithm has only output and it is more like a data structure rather than…

Minor technical correction: tuples don’t require deconstruction syntax; x[0] takes the first element of a tuple in Python, and x.0 in Rust (though it is fun to note that Rust only got that in late 2014, before which pattern matching was the only way of pulling values out of a tuple). For the rest, I maintain my position. :-)

I am mainly inspired by C#. Ok, I can agree, that some things depends on the interpretation. You can think about several returned values as a tuple. In designing Algorithm concept, I was thinking how to decompose or deconstruct a mathematical function - to be able to operate with parameters, to transform input into output. Here You will say that it is the definition of function. Well, I went little bit further. In KatLang it is very important if you use brackets () or {}. Both brackets defines an algorithm, but () cannot hold implicit parameter. Maybe thinking from this perspective will help you see some more value in KatLang. What I wanted to say is that in KatLang I 'destroyed' or 'decomposed' mathematical function and used the parts to construct a concept that in KatLang is called an algorithm.

Re: Show HN: KatLang – Language for Calculations

#27
post #19

Earlier quoted context omitted.

There's at least one type of lambda missing from your paper, the OCaml function. After using the keyword `function`, you can directly go into a match: let toto = function | 0 -> 'a' | _ -> 'b' About the contents of the paper, I'm not sure that I agree with you. There is a clear distinction between lambdas with shorthands and lambdas with named parameters, and I think it exists for a good reason. You seem to base your…

Your OCaml function example looks like feature I call conditional parameters in KatLang (inspired from Erlang). In mathematics exists many different concepts which are called perfect. For example, perfect numbers. God called Lucifer a perfect. I provided a definition for symbols perfectness and tokens perfectness. You can call it unprofessional, but I did my best. I do not call my work perfect to make it more signifi…

> Your OCaml function example looks like feature I call conditional parameters in KatLang (inspired from Erlang).

It does! Elixir (coming from Erlang) and Haskell have the same thing, both through pattern matching of a function to different definitions. OCaml (and most other languages using pattern matching) pattern match inside a single definition.

> In mathematics exists many different concepts which are called perfect. For example, perfect numbers.

I personally only know about perfect numbers. I'm not sure if it's a great name for them, or if it's just a "fun" name like sexy prime https://en.wikipedia.org/wiki/Sexy_prime that doesn't mean much.

For your example about the identity function, I think it's great, but I'm personally more in favour of positional lambdas like &1 in Elixir.

> The question is: can you remove one more symbol without changing the meaning of the expression? If no, then, the identity function definition 'x' is symbols perfect according to my definition.

Maybe "minimal" would be a better name then? Or "shortest"? Many people could argue on what makes the perfect lambda, but it's hard to argue that yours isn't the most minimal or shortest.

Re: Show HN: KatLang – Language for Calculations

#28

Looks good. Curious about the syntax of function declaration - i.e.: A = x * y + x And then I invoke it by: A(2, 3) Implicitly using the order of which the parameters were used in the function declaration. Rather than having it explict either via: A = (x, y) => x * y + x Or via named parameters: A(x = 2, y = 3) Why this design?

I was obsessed with the perfect syntax. Declaring method parameters in method parameters list is redundant, because the parameters appear in the method body anyway. This approach is not the best in all situations, but for short expressions, like lambda expressions, it is perfect (in my opinion). Check my paper on comparing lambda expression implementation: https://www.bjmc.lu.lv/fileadmin/user_upload/lu_portal/proje.…

> parameters appear in the method body anyway

Captured variables too appear in the method body. How do I tell those apart?

Re: Show HN: KatLang – Language for Calculations

#29
post #21

Looks good. Curious about the syntax of function declaration - i.e.: A = x * y + x And then I invoke it by: A(2, 3) Implicitly using the order of which the parameters were used in the function declaration. Rather than having it explict either via: A = (x, y) => x * y + x Or via named parameters: A(x = 2, y = 3) Why this design?

Without trying to speak to why "katlang" does what it does, there are other languages that do this and I can speak to how useful it is when you already prefer functions of low arity: It repeatedly demonstrates a substantial improvement in bug/defect reduction and code. APL does this; a function like {ω×α+ω} and assigns omega to the right-argument, and alpha to the left-argument. They also have ωω for the right-side f…

I will do some research on APL and your mentioned 'commute operator', cannot comment on it now. But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like.

Re: Show HN: KatLang – Language for Calculations

#30

Earlier quoted context omitted.

I was obsessed with the perfect syntax. Declaring method parameters in method parameters list is redundant, because the parameters appear in the method body anyway. This approach is not the best in all situations, but for short expressions, like lambda expressions, it is perfect (in my opinion). Check my paper on comparing lambda expression implementation: https://www.bjmc.lu.lv/fileadmin/user_upload/lu_portal/proje.…

> parameters appear in the method body anyway Captured variables too appear in the method body. How do I tell those apart?

You need to carefully pick the right brackets () or {}. You can define an algorithm with both of the brackets, the difference is that () does not capture the parameter, but {} captures the parameter which is used inside the brackets. When You define a property, then property body is automatically interpreted as defined in {} brackets.
Post reply on HN