Live data from Hacker News

The Phix Programming Language

phix.x10.mx

21–30 of 46 posts

Re: The Phix Programming Language

#21
post #10
post #7

Earlier quoted context omitted.

I know C and implementing a new scripting language for sure doesn't sound easier than using an existing one

Did you ever write an arithmetic evaluator? A calculator essentially? Or any other kind of evaluator? A text template engine perhaps? They all have plenty in common and exist along a continuum of complexity that includes scripting languages and goes all the way to general purpose.

> exist along a continuum of complexity

Isn't that the point? Building a serious scripting language is a huge project. It's far more ambitious than writing a simple text-based calculator.

If you want to build a scripting language worth actually adopting, it's going to have to be far better than Python. That's a very high bar.

The same applies for everything in technology. You could try to write your own OS rather than use an existing one, but it's almost certainly a terrible idea.

Re: The Phix Programming Language

#24

Out of curiosity, what is the purpose of this language? A learning exercise or an attempt to create just another language in the pool of over 1000 already there? Writing an entire language as a way to hone someone's skills is great, even if it is very time consuming vs. the output (skills learned). But I wonder what better options exist.

Probably working together with a group, on an interesting and relevant project. The output will likely be better, and your skills will improve faster - because of the feedback.

Or, for medium scale ideas, maybe taking another language and forking it would be useful.

Re: The Phix Programming Language

#25
post #10

Earlier quoted context omitted.

Did you ever write an arithmetic evaluator? A calculator essentially? Or any other kind of evaluator? A text template engine perhaps? They all have plenty in common and exist along a continuum of complexity that includes scripting languages and goes all the way to general purpose.

> exist along a continuum of complexity Isn't that the point? Building a serious scripting language is a huge project. It's far more ambitious than writing a simple text-based calculator. If you want to build a scripting language worth actually adopting, it's going to have to be far better than Python. That's a very high bar. The same applies for everything in technology. You could try to write your own OS rather tha…

Well, the whole idea is to keep it simple. Look at Lua for a language that can be implemented in a weekend and is still a very serious language. Admittedly, you would probably end up spending a lot of time in the design phase if you were to create your own language, but once you have that, if it truly is a simple language, the implementation is not a problem.

Re: The Phix Programming Language

#26

I don't understand why anyone would create a one-indexed language these days. I feel like Dijkstra laid out pretty well why zero-indexing is objectively better [1]. If that wasn't enough, it's also most common by far. [1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...

You'll typically see it in computer algebra systems whose syntax is intended to be typeset as traditional mathematical notation. Mathematica, for example, wants an array to look like what's being typeset, and it would be confusing (moreso than the potential off-by-one errors) to display `x[3]` while the actual code said `x[2]`.

I think other languages aimed at mathematicians, like Julia[1], do this for similar reasons but, honestly, unless you're writing a CAS, I think it's a bad idea.

Having lived with Dijkstra's ideas for a while, I will say that people find closed-open sequences highly counter-intuitive.

I work on a financial simulator, so we use dates quite a bit. Representing a year as 1-Jan-X up to but not including 1-Jan-(X + 1) is perfectly natural, and really works well with date-time libraries. It still works if you're using dates and decide to extend it to handle datetimes, and even months 1-M-X to nextmonth(1-M-X) do what you'd expect. So he's right, the math works beautifully. You also avoid writing a successor function when you split closed-open ranges; easy with integers, but gets tricky with almost anything else.

But I've had to nag people many times to not use Dec 31. I think the intuition for a closed-closed ranage is deeply ingrained and that extra "Jan 1" seems to stick out and bother people.

From that discussion, here's an interesting argument in favor of 1-based indexing:

> Let me try to briefly convey how I learned to stop worrying and love 1-based indexing. Basically it comes down to the fact that there are three significant numbers you have to think about when it comes to an array: it's initial index, final index, and length. In 0-based indexing, these are all different: 0, n-1, and n. In 1-based indexing, the final index and length are the same: 0, n, n. That's one less thing to think about and keep track of when coding. It seems trivial, but when you're doing something tricky and juggling a lot of complicated things in your head, even the tiniest alleviation of cognitive load helps, I find.

[1]: https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

Re: The Phix Programming Language

#27

I don't understand why anyone would create a one-indexed language these days. I feel like Dijkstra laid out pretty well why zero-indexing is objectively better [1]. If that wasn't enough, it's also most common by far. [1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...

Because zero-indexing is in many cases not natural. Yes, a noted computer scientist made an argument years ago, and it's been cited many times. Perhaps to help you understand, nobody talks about row zero of a matrix. But yes, absolutely, there was a noted computer scientist who made that argument years ago.

Re: The Phix Programming Language

#28
post #10

Earlier quoted context omitted.

Did you ever write an arithmetic evaluator? A calculator essentially? Or any other kind of evaluator? A text template engine perhaps? They all have plenty in common and exist along a continuum of complexity that includes scripting languages and goes all the way to general purpose.

> exist along a continuum of complexity Isn't that the point? Building a serious scripting language is a huge project. It's far more ambitious than writing a simple text-based calculator. If you want to build a scripting language worth actually adopting, it's going to have to be far better than Python. That's a very high bar. The same applies for everything in technology. You could try to write your own OS rather tha…

Worth adopting by who?

I once replaced a convoluted pricerule framework based on fixed options in a booking system with a simple evaluator that exposed variables for number of days, number of guests etc. That was very much worth adopting for that specific use case.

Your line of arguing always assumes that any solution has to cover all bases, which is just not true when you're solving a specific problem.

And no, the same doesn't apply for everything in technology. The continuum for operating systems starts at a much higher level of effort and cost of maintenance. Nothing is black or white.

Re: The Phix Programming Language

#29

> my language is simple, unlike those other 1001 "simple" languages that aren't really Okay. In other words, it seems it's easier to make your own programming language than learn the ones that already exist.

I think it boils down to the fact that the last 10% of any project takes at least 90% of the work. It's easier to make the 90% of a programming language that meets your need than it is to learn a more complete language.

Re: The Phix Programming Language

#30
post #26

I don't understand why anyone would create a one-indexed language these days. I feel like Dijkstra laid out pretty well why zero-indexing is objectively better [1]. If that wasn't enough, it's also most common by far. [1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...

You'll typically see it in computer algebra systems whose syntax is intended to be typeset as traditional mathematical notation. Mathematica, for example, wants an array to look like what's being typeset, and it would be confusing (moreso than the potential off-by-one errors) to display `x[3]` while the actual code said `x[2]`. I think other languages aimed at mathematicians, like Julia[1], do this for similar reason…

Shouldn't the tuple for 1-based indexing be 1,n,n ?
Post reply on HN