Compiler or language enhancements

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Compiler or language enhancements

Post by Tdarcos »

The fact the Hugo Compiler is written in C shows through in a thing I have noticed - and spoken about here before - that the language is extremely weak on: string support. C has horrible string support and most string processing in C is a kluge made using baling wire (but since the string functions are weak, it's not attached with or using string!) to a bag attached by Scotch Tape to the compiler.

Now, you look at a language like the current levels of Pascal, or even Basic, which both have excellent string support, and you realize just how weak the string support is either in C or in Hugo.

And that's one thing Hugo really needs, if there's an update to the compiler, since it's a text-processing application, it needs native string capability. It needs the ability for an object to be a sting and to provide full string processing of strings and possibly string arrays.

If arrays containing characters can be manipulated to compress or expand the array through library functions now, then it's possible to simulate some of these functions, but I think the language needs the capacity for string manipulation, badly. Especially since the game development system TADS was written using Pascal, I wouldn't be surprised if it had better string processing, although I don't know as I've not looked at the language.

Left (take the first N charaters), right (take the last N), mid( take N characters starting at character M), as well as string insert (at character N, insert this string, expanding the string to add this), Len(length of string), string search( find substring in string and return position or 0 if not found).

The ability to handle words not in the dictionaries would be useful but it's not critical. And possibly better math routines but that can be programmed if it's really necessary. The fact that the Hugo compiler doesn't support real numbers is another artifact of it's days as a 16-bit application where floating point operations required either a coprocessor - floating point being not included in the base CPU and often costly to add as a coprocessor - or expensive software-based floating point.

I mean, even PHP, which is based on C, has fairly good string processing functionality.

So, does anyone else have ideas of things the Hugo language either needs better support for or that it should have as additional capability?
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

User avatar
RealNC
Posts: 2246
Joined: Wed Mar 07, 2012 4:32 am

Post by RealNC »

C has nothing to do with Hugo string support. C gives you the tools to implement something. What you implement with it is up to you. In no way can C dictate that you use its data types in your own language implementation.

If you write a C compiler in Pascal, you will implement C strings in Pascal. If you implement a Pascal compiler in C (most common case), you will implement Pascal strings in C.

CLOWNSHOES

Post by CLOWNSHOES »

It doesnt matter, Nikos. He is never going to get it. He read on the internet that C is "weak" with strings, so he will now try to infer that every singlr program in the world that is written with C is similarly "weak."

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

RealNC wrote:C has nothing to do with Hugo string support. C gives you the tools to implement something. What you implement with it is up to you. In no way can C dictate that you use its data types in your own language implementation.
Yeah, but implementing any data structure that is not supported natively means you either have to write a lot of code or hope you find a library pre-built for the feature.

If Hugo didn't include the standard libraries (verblib.g & .h, hugolib.hug) it would take a lot of work to write an adventure because you'd have to code all of the verb processing. As it is, the standard libraries do a lot of the "heavy lifting" necessary to process a lot of commands natively.
RealNC wrote:If you write a C compiler in Pascal, you will implement C strings in Pascal. If you implement a Pascal compiler in C (most common case), you will implement Pascal strings in C.
Uh, for your information, I am a regular collector of program compilers. I have never seen a single implementation of a minimum K&R or ANSI-class C compiler done in anything except C. In fact, I can't remember any Pascal implementation of even a toy-class C compiler. C compilers are always self-hosting.

I'm not saying there aren't any Pascal-hosted C compilers, I've just never seen one.

As for Pascal, I've seen or acquired sources for perhaps ten Pascal Compilers and I've read manuals from probably another dozen where either they admit the compiler is written in Pascal or they specifically mention it requires code to interface with C because it's not written in C. And I only know of two instances where C was used.

The Free Software Foundation's Pascal Compiler is written in C because it's a frontend to its GCC compiler collection which originally was the Gnu C Compiler. There is perhaps one other C-based Pascal Compiler, I think it was a reimplementation of the Surpas subset compiler which itself was originally written in Pascal.

Since Wirth was originally working on the CDC Cyber Mainframe, the first Pascal compiler was written in FORTRAN because the NOS operating system has very good support for Fortran, and once the compiler had been compiled, it could then compile itself. Since then, with the exception of GCC, all Pascal compilers have been self-hosting.

So, out of perhaps 30 different genres of Pascal compilers, there are perhaps 2 written in C, the rest are self-hosting, meaning that almost all Pascal compilers are themselves written in Pascal.

The Free Pascal Compiler is one of the most powerful object-oriented Pascal compilers in existence, it is 261,804 lines of code, compiles to 208 units plus a main program, and produces an executable of approximately 11 megabytes on Windows. It is written in Pascal.

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

CLOWNSHOES wrote:It doesnt matter, Nikos. He is never going to get it. He read on the internet that C is "weak" with strings, so he will now try to infer that every singlr program in the world that is written with C is similarly "weak."
Try again, fella. I didn't "read on the Internet" that it's weak with strings, I've read C language programs and know from personal experience that it is weak on string processing. I was reading C programs back in the 1980s, before the Internet was available to the general public, back when BBSs were the dominant means for individuals to transfer files from place to place.
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

Post Reply