4 ms·
Japanese is a head-final, strictly left branching language, as linguists might put it, which means it's structured like postfix. This would actually let you re
by T-R 16y ago
Japanese is a head-final, strictly left branching language, as linguists might put it, which means it's structured like postfix.
This would actually let you read code strictly left-to-right (even though English speakers would be tempted to think of it as right-to-left) - when you read through functional programs, you end up reading a lot of the code right-to-left, due to function application, to see the order that code is actually executed. In postfix, the order objects/functions are written is the order they're executed.
Continuing along the lines of the post, a more Japanese programming language would also have named arguments (particles), and if it was object oriented, you wouldn't need to type 'this'/'self', since subject can be implied by context (well, it's really the direct object - the computer is the subject).
- overgard 16y agoInteresting point with regards to functional programming, although it's worth pointing out that at least some functional languages have operators that allow you to do what you're describing. For instance, in F# instead of writing "f x" you can write "x |> f"
- ionfish 16y agoFor functions of one argument that's easily enough defined in Haskell. x |> f = f x
- overgard 16y agoI don't know Haskell very well, but I assume you're defining an |> function? If so that's pretty neat. Haskell's flexibility always impresses me. I think the F# version generally assumes one argument too, though I think you could use partial function application to work with multiple parameters.
- ionfish 16y agoYes, that's right. Infix function names (anything made of symbols or delimited by backticks) are allowed on the LHS of a defining equation. An alternative syntax for this function would be this: (|>) f x = f x The parentheses just serve to denote an infix operator being used in a prefix way. A type signature makes this clearer: (|>) :: a -> (a -> b) -> b As you can see, (|>) is a function which accepts an argument of type a, a function which takes an argument of type a and returns something of type b, and returns something of type b. In this way it's just a flipped version of the application operator ($), which has this type: ($) :: (a -> b) -> a -> b
- T-R 16y agoI was just thinking about that. You have to do it by hacking the infix syntactic sugar. x |> f = f x gives you lambda calculus, but it gets ugly, since you need to specify order of operations with parentheses. (4 |> (5 |> (+))) |> (3 |> (*)) You can take it a step further with tuples, but you still need to be explicit about the number of arguments: (x,y) |> f = f x y ((4,5) |> (+), 3) |> (*) Maybe you could go almost all the way by telling it to create a List when passed two values, and telling it apply to the (nested) List when called with a List and an operator, but off hand, I can't think of a way to get it to type check, particularly not without killing currying.
- sjs 16y agoInteresting, in Ruby you don't need to type `self` when calling instance methods within the same class.
- alinajaf 16y agoIIRC this is also the case with Java