Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Comment Re:Smalltalk made new keyword creation easy in 198 (Score 1) 158

So does this mean that Tao3D is call-by-value by default, and this explicitly breaks it to (effectively) call-by-value, rather than leaving the programmer to hack around with statics or constants and individual copies of arguments?

The locally function is conceptually equivalent to running its argument surrounding it with graphics state save/restore code. That's about it. So you can't deduce anything about call-by-value from it.

Now, to address your question in short, XL uses call-by-reference, and lazily evaluates the arguments as required to perform the call. Cases where you need to evaluate include: having to check against a type that is not "tree", comparing against a pattern, comparing for identity between arguments. For more details, see section 3.3. "Evaluation" of https://raw.githubusercontent..... You can also explicitly evaluate something with 'do'. In the 'if-then-else' definition given elsewhere, there is a 'do' for the bodies, to force evaluation of only that argument to if-then-else corresponding to the condition. If the condition is true, you only evaluate the true clause. If it's false, you only evaluate the false clause.

Comment Re:Smalltalk made new keyword creation easy in 198 (Score 1) 158

Semantic whitespace makes me sad. :-(

Maybe you never had to work in a large project where the project most productive guy did no care about indentation at all. Whitespace has a semantics for our brain, so we might as well make that consistent with the code. It reduces syntactic noise, in concept programming jargon.

Comment Re:Grammar ? (Score 1) 158

having noted the somewhat high-nosed, arrogant tone of your answer

Too bad you failed to note how high-nosed and arrogant your own "Seriously...!" sounded :-)

Anyone into compiler construction and wanting to / trying to use your language would want a grammar

Let me disappoint then. I don't think you can even write a valid EBNF for XL, it's too dynamic for that. Let me explain why.

First, scanning and parsing are really very simple. The scanner is 747 lines of code with comments. The parser is 659 lines of code with comments. The scanner produces a stream of tokens. The parser produces an abstract syntax tree built with exactly 8 node types: integer, real, text, name, infix, prefix, postfix or block. The abstract syntax tree is used both for code and for data. A list such as 1,2,3,4 is really a sequence of infix "comma" nodes with integers as leafs.

What makes it difficult to produce a valid EBNF for XL is that the precedence rules between operators are dynamic. They are initialised from a file called xl.syntax, but they can be changed at run-time. So, of course, I can write an EBNF for if-then-else that would be something like:

if then else = "if" condition "then" statement "else" statement

But that would be imprecise. In reality, with the default syntax, if X then Y else Z parses as (infix else (infix then (prefix if X) Y) Z) (using a Lisp-like notation). That happens because of the specifications of infix priorities for then and else given in xl.syntax. Furthermore, the meaning of this particular parse tree is only given by a "rewrite", i.e. a definition such as if X then Y else Z -> ifthenelse(X,Y,Z). It is intentionally not given by a grammar of any kind. Definitions like this are even more dynamic than the priorities. They are the XL equivalent of functions, so you use them all the time.

Even writing a valid EBNF for integer literals would be hard. XL accepts 16#FFFF_FFFF as a valid integer, but 12#FFFF is not valid because F is not a valid digit in base 12. Ada has the same problem, and most EBNF descriptions of based literals for Ada are wrong. This one for example over-simplifies things and considers 12#FF# as a valid number when I assume any valid Ada compiler would reject it. Of course, you could enumerate all the 36 cases to have a valid EBNF that actually represents the language, but at some point, you have to ask: "what's the point"? And if the idea is to describe a language that is only approximately XL, taking more space to do so than the valid C++ code describing what XL actually is, then that's another big "what's the point" in my book.

Finally, there are a number of priority-based shenanigans that were introduced to make the language easier to use, but make it even more complicated to describe in EBNF or anything like it. Here are two examples.

When you read write -A, you normally read this as "write(minus(A))". On the other hand, if you write A-B, you probably read this as "minus(A,B)". It's not logical, but that's how we read. That leads XL to pay attention to spaces surrounding operators to decide what you mean. I hear you "yuck", but it just works.

Another scenario is even worse. Consider write sin x, sin y. All the people I tried that with read it as "write(sin(x), sin(y))". Problem is that this reveals a priority inversion in our brain. If the comma has lower precedence than function calls, then it should read as write(sin(x)), sin(y). If it has higher precedence, then it should read as write(sin(x,sin(y)). None of them is right. For this reason, XL and therefore Tao3D have a notion of "expression vs. statement" implemented in the parser. Again, it's "yuck" for formal grammar nazis. But again, I don't care, because it just works.

Comment Re:Smalltalk made new keyword creation easy in 198 (Score 2) 158

Your post is long, so I'll only address a few snippets by lack of time.

Also, why do people keep making new languages with new syntax (generally with poor to missing error messages, debuggers, IDEs, documentation, and libraries) when we would so much more benefit from improved FOSS libraries for existing ones? I'd be a lot more excited about Tao if it was a JavaScript library that just supported some special format INI files.

The answer is complex. I try to address it in this article. It's not just for the sake of inventing a new language, it's because what I wanted to do I could not do with JavaScript.

Looking at a bit of the Tao overview video on SourceForge, it looks like variables don't need to be declared (ick!).

Variables need to be declared, but an assignment does declare a variable in that scope.

Also, requiring "locally" seems to imply that it has one of the worst "features/bugs" of JavaScript design for default globals? Or maybe I did not understand "locally".

The 'locally' function does not concern variables, but graphic state. It's a way to say "I don't want this rotation to escape this block". In OpenGL terminology, you can think of it as a PushMatrix/PopMatrix pair (and same for other attributes).

The main aspects of the language (like what is a code block, what is an argument) don't seem clear at first glance to me, perhaps because of various keywords being defined or seeing commas some places and not others?

I find the use of a comma without inner parentheses interesting for functions and arguments, where the comma in a sense is doing what Smalltalk keyword colons are doing. Still, it misses labelling arguments like Smalltalk, and why not drop the commas and just have all arguments separated by spaces and instead require nested expressions to be surrounded by parentheses if you are going in that direction? For example: "translate -500 100 (10 + x)"

If you define something like:

        translate X Y Z -> translate X, Y, Z

then you probably are close to what you want. In practice, this forced me to add many parentheses (as you just did), and I found using a low-priority comma to separate arguments was much more practical.

I like the clean looking syntax without semicolons at the end of lines. I'm assuming it uses indentation after a comma to define code blocks?

Yes.

It it ran on JavaScript, maybe I'd try it today...

If someone wants to give Emscripten a try ;-)

If you're the author, despite any criticism above (just half-baked opinions from watching the video for a few minutes on-and-off while writing this), I'd still encourage you to keep moving forwards with it. Looks like a lot of fun! And it is exploring some new ideas and the library looks amazing. There is no question popular computer languages (Java, JavaScript, C++) have many warts and someday it would be great to have better languages (again though, Smalltalk and message passing is my favorite, even as I move to JavaScript now for various reasons).

Thanks for the encouragements.

Still, if you haven't already, you might want to make an ANTLR ( http://www.antlr.org/ ) grammar for Tao3D and generate JavaScript for a backend to the animations which uses asm.js for speed and so it can run easily in a web browser. Then people with a compatible recent browser could just click on a link and be up and running with Tao.

I have other plans to achieve that same effect. What out for Buddda ;-)

Comment Re:Most uninteresting (Score 1) 158

Common Lisp macros allow you to create complex language extensions which are not library functions. They perform as though they are built in. Before anyone writes a "new" language they should at least survey the already existing solutions.

Yes. You can actually see XLR as a Lisp without the parentheses.

Comment Re:Most uninteresting (Score 1) 158

OK, game on. Give me the syntax for the following in Lisp, Scheme, OCaml, whatever:


import Slides
slide "Example",
        * "First bullet point, with seconds: " & seconds
        * "Second bullet point"
        ** "Second level bullet point"
        blink
                * "Third level bullet point"
        anchor
                translate mouse_x, mouse_y, 200 * sin time
                color "white"
                texture "http://www.planetaryvisions.com/images_new/4128.jpg"
                rotate_y 20 * time
                sphere 200

Things like blink, anchor or slide are all functions, of course.

Comment Re:Point? (Score 1) 158

The project actually started in 2009. And I'm not even sure that WebGL is mature enough today for some of the things we do. It's not so long ago that Microsoft adopted it. And hey, it can't even display the background shaders on http://tao3d.sourceforge.net..... Enough people started complaining that I had to remove them.

So if WebGL is not good enough for a web page, I doubt it would be good enough for many of the features in Tao3D. But one benefit of open source is that you can try and transcode it in JavaScript and see how well it works. I'm really interested to see you display 3D extruded arabic text on your 2011 Blackberry ;-)

Comment Re:Things you need to fix if you want users (Score 1) 158

What are the objections of the people you know to GPLv3 for a new project? I know of the objections for Linux. I also know why I like GPLv3.

The website uses Reveal.js, a presentation framework for the web. I find it useful for tutorials and such. You don't have to like it any more than you have to like the GPL v3.

I am the author of XL. So I guess I don't get it twice then ;-)

Comment Re:Most uninteresting (Score 4, Interesting) 158

Where did you see an example of the language? The links went to sourceforge (I didn't want to install the package just to see the language) and a marketing video.

There are a few code examples in the marketing video. There are several additional examples on the Taodyne web site, but I'm pretty sure it can't take a slashdotting.

I'm curious how anyone thought that if/then/else was a difficult enough construct in popular languages such that it needed improving. I mean, it's a couple of lines of code in *any* language, isn't it? Anyone know how this language supposedly improved on the concept?

The idea is that in other languages, if-then-else is a built-in construct. You can't do something similar yourself without hacking the compiler. In Tao3D, if-then-else is a library element like printf in C. So you can change it.

Let's say you often use a specific kind of for loop. In Tao3D, you simply add the notation you need, and now your code is shorter and more concise. Once you decide that one of the language objectives is that you can extend it yourself and create your own domain-specific languages, it's obvious that a good test for that feature is to use the basic programming language constructs found in other languages, like if-then-else or for loops.

So, functions are first class data members? Is it weakly typed then, like Lua? In that language, defining a function is just syntactic sugar for assigning a chunk of code to a variable of the assigned name, so you can use it just like any other variable.

The part that is always verbose in existing functional languages (except maybe Lisp) is how you pass code to another function. For example, in Javascript, you'd pass a callback with 'function() { ... }'. In Tao3D, I got rid of everything but ..., and the language is smart enough to figure things out. This means that you can define a slide by passing bullet points, and it almost looks like Markdown, whereas if I was in JavaScript, I would need layers and layers of code. This particular aspect is detailed in an article called "Storytelling, the web is doing it wrong"

In Tao3D, you define the notations you want first, you design the (domain-specific) language around your notations second. In existing languages, it's the other way round, the notation is imposed by the language you chose.

I'm also curious what this particular brings to the table that a library couldn't have accomplished. Learning a new language is a fairly big hurdle for someone to take to develop for a particular platform. Part of the reason I think we have so many computer languages is that programmers simply love writing new languages, not that it really solved any new problem. Nothing wrong with that, but then again, don't expect us to care unless there was a good reason for the new language.

That's a very good point. The reason for XLR (the language underlying Tao3D) was that we have to invent new languages all the time, not because we like to, but because existing languages are very bad at accepting something that is not already in their DNA. You could not get lambda functions in C++ until the language committee sat around a table, standardized it, and then all compiler vendors had to implement it. But if what you need is for example a notation for symbolic derivative, or a notation for slides, or a notation for a specific kind of for-loop, you are stuck. So progress in programming languages is very slow, because each language adds its own little features, but drops tons of other features that already exist in other languages.

The idea with XLR was to create a language where the fundamental process was extending the language. And Tao3D is an example of a relatively large scale domain-specific language (specifically around 3D and animations). Most of it is precisely in a library. But you wouldn't know from using it. It feels "native".

Slashdot Top Deals

To write good code is a worthy challenge, and a source of civilized delight. -- stolen and paraphrased from William Safire

Working...