Introduction to Hugo

Hugo programming discussion. http://www.generalcoffee.com/hugo
Hugo By Example: http://hugo.gerynarsabode.org/index.php?title=Main_Page
Roody Yogurt's Hugo Blog: http://notdeadhugo.blogspot.com

Moderators: Ice Cream Jonsey, AArdvark

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

Introduction to Hugo

Post by Tdarcos » Sat Nov 02, 2019 7:32 pm

Introduction to the Hugo Interactive Fiction Authoring System
by Paul Robinson

The Hugo Interactive Fiction Authoring System and Programming Language is a system for specifying the commands, and responses to the commands, necessary to construct an Interactive Fiction story, or more specifically, any application which could accept typed in command instructions and provide varying responses to those commands, based upon what the user has typed in before or what has happened within the application previously. It is also possible to develop a graphical style interactive Fiction story, using images and mouse clicks, but, since this is just an introduction to Hugo I'm going to keep things simple in general, and discuss mostly text-based stories.

The Hugo Programming Language is what is called a "domain-specific language." As Wikipedia put it, "A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains." What Hugo is specialized for, is the specifications of commands used to manipulate the character the person running the story is playing, the places that character could visit, and the objects in the various rooms (or within other objects) or carried by the player's character.

While Interactive Fiction is the primary focus of Hugo, it is not the only potential use of the language. Even in text-only mode, the Run-Time System supports multimedia, allowing the playing of sounds, showing of pictures, and even video playback. Another types of applications Hugo could be used to produce, for example, is tp create a model of a building where images of floors could be shown, and also described in prose, where a person moves from room to room and floor to floor, It might be useful in the case of something intended for blind persons as a text-to-speech program could provide descriptions of areas, something not possible with images.

You might ask why you would want to use Hugo to write an Interactive Fiction story as opposed to some of the other Interactive Fiction Authoring Languages. Hugo provides a much easier language to write Interactive Fiction while not sacrificing the richness of features and capacity to write even very complex stories. Its means of specifying commands, objects and routines to process commands are straightforward, and fairly intuitive. Hugo tends to "get in the way" much less than other Interactive Fiction authoring languages that make writing specifications for a story difficult. As mentioned earlier, Interactive Fiction authors with more experience can use Hugo to develop graphical mouse-driven stories.

As was stated earlier, Hugo is a domain-specific language, it is designed to handle certain types of applications. You would not want to use Hugo to write a payroll program (for one thing, it has no database functions), but for what it is designed to do, it does very well. In a program written using the Hugo languagr, it is necessary to specify all of the potential commands the user could type in, the routines to handle those commands, the places that exist within the stiry, and the objects that are found there.

Now you do not have to do everything, the standard Hugo library has predefined objects which define things like rooms, properties of objects (characteristics such as whether the object is movable, enterable, can be picked up, or, (in the case of a room) either lit or dark), and variables relating to the object (the object's name, description, where it is located, if it has something inside of it, and for a room, its title, its description, the directions you can travel and what happens if you do.) Hugo also supports the creation of Non-Player Characters (NPCs), other "people" the user of the story can interact with, and NPCs can be a friend, or an enemy, of the player.

The standard library includes a large number of predefined commands to provide "generic" responses to most commands, e.g. "take", "push" or "pull" followed by the name of an object will provide the common expected result of that command applied to that object, or, if the properties of that object do not allow that command, an error message is given. If a particular command works differently for a certain object (e.g. if you are in a bathroom, "take book" would mean something entirely different from "take shower"), then you can either provide a special command or a specific operation for that particular object. Hugo also supports "events" where things can happen after a certain number of commands are issued, e.g. walking more than 5 moves in a pitch-black room or rooms causes the player character to break a leg, fall into a pit, etc.

Like many other programming languages, Hugo has certain structure requirements. First, you define any commands (or include the standard library and add additional commands as needed) which tell what routine (what Hugo calls a procedure) will handle each of those commands. Next, you define the various rooms and objects (or additional ones added to those in the standard library), and declare the routines to handle the new commands. Next, you declare the initialization routine that sets up anything necessary to be done at the start of the game, then you define the "main loop" which is run once each turn.

Hugo supports inline inclusion of source files, so stories can be broken up logically, so commands may be defined in one file, rooms defined in another (or a group of related rooms), scenery (objects that are merely descriptive but can't be interacted with), objects the user will interact with, and routines to process commands can all be in separate files.

At any point in the development of a story, that you feel it is at least somewhat playable (in order to test it) you can save the current story files (Hugo source code is simply several text files, and any text editor that produces plain ASCII files can be used to edit them), then "compile" the source using the Hugo Compiler If there are no syntax errors, the output of the compiler (a file with a name ending in .hex) can be passed to the Hugo Run-Time System for execution. Then you can return to editing the appropriate files to fix errors or add more details and/or features to the story.

Hugo comes with the compiler, run-time system, source to the run-time library, a sample template stub for designing a story, a sample game, a reference manual, and (not required to create Interactive Fiction stories) sources in C to the compiler and run time system.

Licensing for the system is clear. It is given away for free from several places including https://www.ifarchive.org/if-archive/programming/hugo/ Redistribution of source for free is permitted; redistribution for profit is not permitted. Redistribution of the Run-Time System binary to permit a user to run a story and with necessary multimedia files, if any, for free or for profit is permitted.

There are additional third-party options to replace the standard support files for Hugo programs to provide improved functionality. A user with the handle Roody Yogurt has released a replacement for the standard library which is called Roodylib and provides improved features. A user named RealNC has created a replacement for the Hugo Run Time System called HugoR which provides 32-bit and 64-bit support for Windows and Linux.

Hugo provides an excellent language for the development of Interactive Fiction, with a gradual learning curve for new users while providing even advanced features for experienced users. If you are considering developing an Interactive Fiction story, Hugo just might be the better choice over other alternatives!
"I know what you're doing, I see it all too clear."
- Duncan Sheik, Barely Breathing

User avatar
pinback
Posts: 13409
Joined: Sat Apr 27, 2002 3:00 pm
Contact:

Re: Introduction to Hugo

Post by pinback » Sun Nov 03, 2019 6:20 am

Image
Above all else... We shall go on... And continue!

User avatar
bryanb
Posts: 113
Joined: Sat Apr 06, 2019 2:56 pm

Re: Introduction to Hugo

Post by bryanb » Sun Nov 03, 2019 12:51 pm

I remember when Hugo first came out. I was at an IF convention at the time and spent the whole afternoon asking participants, "What IS IT?!" I wanted all the details, but I kept getting jargon-filled and overly complicated answers that only seemed to raise more questions. Finally, though, I got an answer that even I could make sense of. "Oh, a magic door! Why didn't you say so?!" I exclaimed. That's what Hugo is: a magic door to other worlds and other realms.

Great write-up, my friend.

User avatar
Ice Cream Jonsey
Posts: 21961
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Re: Introduction to Hugo

Post by Ice Cream Jonsey » Sun Nov 03, 2019 2:05 pm

I don't think Hugo is a domain specific language.
the dark and gritty...Ice Cream Jonsey!

User avatar
Flack
Posts: 6171
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Re: Introduction to Hugo

Post by Flack » Sun Nov 03, 2019 5:24 pm

> TAKE GUN
You pick up the gun.
"Jack Flack always escapes." -Davey Osborne

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

Re: Introduction to Hugo

Post by Tdarcos » Tue Nov 05, 2019 7:32 am

Ice Cream Jonsey wrote:
Sun Nov 03, 2019 2:05 pm
I don't think Hugo is a domain specific language.
Okay,, explain how you write a payroll program using Hugo. Or a calendar. Or a text editor. Or an alarm clock (wrote one once using GWBasic.) Hugo lacks certain features such as database support, date and time functions, and either dynamic arrays or pointers and memory allocation.

What Hugo can do, is handle commands (or, if designed for a graphic one, mouse clicks), and responses to them. It is designed to provide support for the creation of interactive fiction (and the execution of that creation) or possibly a few other minor applications that can be done with what capabilities Hugo does have. And to that extent, for what it can do, it does a fantastic job.
"I know what you're doing, I see it all too clear."
- Duncan Sheik, Barely Breathing

User avatar
Ice Cream Jonsey
Posts: 21961
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Re: Introduction to Hugo

Post by Ice Cream Jonsey » Tue Nov 05, 2019 7:44 am

Tdarcos wrote:
Tue Nov 05, 2019 7:32 am
Okay,, explain how you write a payroll program using Hugo.
You'd use text files that you can read and write to, like you would if you tried to do such a thing in Pascal.
Or a calendar.
You need to be more specific on this one.
Or a text editor.
Seeing how it can do Tetris, it can do a text editor. Again, due to the fact that you can read and write to files, you can edit text. Are you really using "inability to manipulate text" as your argument for Hugo being a DSL?
Or an alarm clock (wrote one once using GWBasic.)
This one is easy. Enter the time you want the alarm to make a sound. Make a sound in a resource file. Create a loop that reads the system time versus the time you want the alarm to go off. When that happens, play the sound and exit the loop. Cryptozookeeper starts new music at the top of the hour in order to keep the math right, so the same routines would be used for this.
Hugo lacks certain features such as database support
BASIC and Logo don't have "database support." Are they domain specific languages? What makes you think database support is necessary? SQL has database support and it IS a domain specific language.
date and time functions
This is not correct.
and either dynamic arrays or pointers and memory allocation.
Java doesn't have pointers, those are not important to this discussion. Hugo does allow for memory allocation. I think you can resize arrays in Hugo but I don't remember. Maybe you can't, but that has nothing to do with DSLs.
What Hugo can do, is handle commands (or, if designed for a graphic one, mouse clicks), and responses to them. It is designed to provide support for the creation of interactive fiction (and the execution of that creation) or possibly a few other minor applications that can be done with what capabilities Hugo does have. And to that extent, for what it can do, it does a fantastic job.
Sure, but your understanding of what a domain specific language is is incorrect. You're thinking of something like the code in GameMaker, which can only ever interface with GameMaker Studio. Or HTML, LaTeX and SQL, which are not Turing Complete. Hugo can solve any computational problem.
the dark and gritty...Ice Cream Jonsey!

User avatar
Ice Cream Jonsey
Posts: 21961
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Re: Introduction to Hugo

Post by Ice Cream Jonsey » Tue Nov 05, 2019 10:34 am

I talked to some people on the ifMud about this. Some people were adamant right away that, yeah, Inform, TADS and Hugo were all DSLs. Further discussion brought up the idea of intent - and in that case I agree completely, the intent of Hugo and the other two text game languages is to make text games, not be general purpose languages.

Furthermore, while Turing complete is used in DSL definitions, it is not the end-all - the Game of Life and Minecraft are Turing complete, but not programming langauges per se.

That said, further discussion brought up the idea of a range. The most general purpose language I can think of is C. The least general purpose language I can think of is the implementation of BASIC for the Atari 2600 cartridge "BASIC Programming." Other languages are on that range. Hugo would definitely be more towards the DSL side than something like Java, LISP or C++, but not as far as bash, the language inside the PC game Rocky's Boots or CSS.

This has been a stimulating and interesting conversation where I learned something about computer science and I thank Tdarcos for bringing it up!
the dark and gritty...Ice Cream Jonsey!

User avatar
Flack
Posts: 6171
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Re: Introduction to Hugo

Post by Flack » Tue Nov 05, 2019 8:36 pm

Tdarcos wrote:
Tue Nov 05, 2019 7:32 am
Okay,, explain how you write a payroll program using Hugo.
> DEPOSIT CHECK
You deposit your check.
(Your score has increased by one.)
"Jack Flack always escapes." -Davey Osborne

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

Re: Introduction to Hugo

Post by Tdarcos » Wed Nov 06, 2019 3:16 pm

Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Tdarcos wrote:
Tue Nov 05, 2019 7:32 am
Okay,, explain how you write a payroll program using Hugo.
You'd use text files that you can read and write to, like you would if you tried to do such a thing in Pascal.
Excuse me, but ever since UCSD Pascal from probably 30 years ago, Pascal has had the "seek" procedure allowing one to move the read or write pointer to a specific byte in a text or other disk file. Hugo does not support random access to files. Nor file locking. (So you can't use it in a multiuser environment.) Nor can it call external routines. In fact, I remember seeing a set of procedures written in Turbo Pascal 3 to read, write, select a record by key, and create dBase III files.

Current Object Pascal derivatives like Free Pascal with Lazarus and the Component library support access to MySql databases and ODBC database connectors as well as abstraction layers to allow a program to use a general record select request or read or write request and have it translated for any of the major SQL variants (MySQL, Postgres, DB2, Access, Oracle, SQL Server, and probably others). If you change underlying databases you just change the ODBC request and the program will still work the same way, the abstraction layer does "all the heavy lifting' to convert to the specific SQL commands for the new database system.

And if what you need to do requires calling a system function, Pascal can do so as completely as Visual Basic or C++.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Or a calendar.
You need to be more specific on this one.
A calendar program today almost always means a program to store and retrieve events posted for individual or specific days (like every Thursday or your spouse's/significant other's birthday.)

I was not aware Hugo supported retrieving the current date and time. So I was wrong on this one.

Or was I?
There is no reference to date or time in the index to the reference manual. This could be why I thought there was no date or time functionality in Hugo. I found current time buried as an argument to the system instruction. but one thing Hugo does not have is the function to obtain the current date. Basic, Pascal, C, and COBOL all have built-in or system library support for retrieving the date and time. Having both, or lacking either, could be a significant factor in whether or not a programming language is a DSL or even a "toy" language

If I am wrong, please specify the page in the manual where it provides for the current date to be retrieved.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Or a text editor.
Seeing how it can do Tetris, it can do a text editor.
You're probably aware of this but might have done it to see if I'd notice. And to use an analogy, I caught you dealing seconds. You used the logical fallacies of a false comparison and a non sequitur. Just because a language works to develop one type of application, it does not follow that it can be used for something else.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Again, due to the fact that you can read and write to files, you can edit text.
A text editor must be able to change characters anywhere in the document. Even granting you might be able to do this on disk (as opposed to memory) it would probably be too slow to be useful.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Are you really using "inability to manipulate text" as your argument for Hugo being a DSL?
Yes. That it lacks random access to files is another push in that direction.
Or an alarm clock (wrote one once using GWBasic.)
I'll give you this one as I had missed where you get current time.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Hugo lacks certain features such as database support
BASIC and Logo don't have "database support."
Visual Basic did and even GWBasic had some form of seek function which would allow random access to read or write files. Which means it's possible to use some database files such as dBasr III.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
Are they domain specific languages? What makes you think database support is necessary?
Database support is necessary to support most serious applications, the "bet the company" apps real businesses need to operate. Payroll, Billing, Accounts Receivable, Accounts Payable, Check Writing, are all heavily dependent on random access file operations and/or databases. COBOL has had at least random-access files since what, 1959?
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
SQL has database support and it IS a domain specific language.
Regular SQL lacks many features even Hugo has. Looping (while, repeat, until); IF tests; GOTO or some equivalent to skip blocks of code; FOR loops; language procedures (as opposed to database procedures) and functions; arrays and other things. Advanced SQL has so many features that it might have "broken out" and become a full GPL.

Oracle MySQL's manual exceeds 6,000 pages, the database system has so much functionality it might have jumped the gap and escaped the "DSL ghetto."
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
date and time functions
This is not correct.
Oh yes it is. Hugo has no date function.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
and either dynamic arrays or pointers and memory allocation.
Java doesn't have pointers,
If it doesn't have pointers it has to have dynamic arrays or an equivalent. Editing a 100,000 byre file or multi-megabyte fle, or having multiple files open in tabs requires a way to handle the many edits on each file. Disk-based storage would be too slow for this.
Ice Cream Jonsey wrote:
Tue Nov 05, 2019 7:44 am
What Hugo can do.., to that extent, for what it can do, it does a fantastic job.
Sure, but your understanding of what a domain specific language is is incorrect. Hugo can solve any computational problem.
Hugo lacks date support, random-access file support, event timers, direct hardware access, ability to call external routines, and other features crucial to some problems.

You could not use Java, COBOL, Fortran, minimal Basic or Hugo to write an operating system or device driver. These require a full-service (or perhaps First Class) General-Purpose language such as C, Object Pascal, or Advanced Basic,
"I know what you're doing, I see it all too clear."
- Duncan Sheik, Barely Breathing

User avatar
Flack
Posts: 6171
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Re: Introduction to Hugo

Post by Flack » Wed Nov 06, 2019 3:45 pm

I can't imagine a better way to welcome people to Hugo.
"Jack Flack always escapes." -Davey Osborne

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

Re: Introduction to Hugo

Post by RealNC » Sun Nov 10, 2019 4:16 am

Flack wrote:
Wed Nov 06, 2019 3:45 pm
I can't imagine a better way to welcome people to Hugo.
https://www.youtube.com/watch?v=80zJUALIYHg

Post Reply