Welcome, Guest. Please login or register.

Author Topic: creating a text adventure, but with what programming language?  (Read 16650 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Quote from: ChaosLord;603440
True BASIC has the absolute best string handling of any language ever.


I would rank Perl and PHP as far above any BASIC dialect in terms of string processing capability ;)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #1 on: January 03, 2011, 10:04:39 PM »
Quote from: ChaosLord;603617
But then you would be wrong. :)

:roflmao:

Sure. BASIC is better at string manipulation than Perl/PHP.

Thanks, that made my day!
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #2 on: January 03, 2011, 10:44:02 PM »
Quote from: runequester;603622
No fighting guys :)


I'm not advocating the writing of text adventure games in languages like Perl (though I am sure it has been done), but the point has to be made that manipulation of text was one of the main motivations of Perl in the first place. It may be old and it may be a beast but every language has it's milieu and chewing on textual data is Perl's.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #3 on: January 03, 2011, 11:36:00 PM »
Quote from: ChaosLord;603634
@Karlos
Ok go ahead.  Show me in Perl how to extract a 3 characters string from another string starting at the 5th character and then insert that extracted string into another string starting at the 20th character.

Well, I'm more of a C/C++ guy but I am at least aware that the substr() function in Perl can also be an lvalue, which allows all kinds of useful manipulation of the type you are asking for:

http://perldoc.perl.org/functions/substr.html

And that's not even using regular expressions, for which I'm sure the next PCRE expert will produce some 8 character expression to do your task. ;)

But of course, nobody would be using absolute string positions, right? Terribly bad form if you want to support minor things like alternative character sets and foreign languages.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #4 on: January 04, 2011, 12:10:29 PM »
Quote from: ChaosLord;603691
Trying to compare Perl to a language that was actually designed to handle strings efficiently is just not going to work out that well. :)


I'm sorry but you simply have no idea what you are talking about if you think that Perl is surpassed for string manipulation by BASIC.

Perl has been text processing for the masses for over 20 years. The language was created to process text efficiently, which necessitates efficient string handling at every level, from basic search/replace down to how strings are allocated. There is not a string-manipulation task you can think of that it can't already do in half a dozen different ways, most of which do not require anything beyond the language syntax itself (ie, you don't even need to invoke a function).

You need look no further than the fact that regular expressions are actually built into the language and Perl Compatible Regular Expressions (PCRE) have become the yardstick by which most other regular expression processors are measured against. You can't have a bigger lust for string manipulation in a language than that.

Your cited example of reading substrings and inserting them elsewhere is laughably insignificant compared to the power and flexibility of PCRE alone. Without even using their most powerful constructs (I was using PHP's PCRE implementation), I got this site working in classic browsers with all the necessary rewriting of HTML, stripping of CSS etc. on the fly that this entailed. Not just a bit of search and replace, entire transformations where a CSS popup menu matched in one part of the document becomes an option select with javascript trigger in another just so that you can have some of the functionality of the main site in IBrowse. The entire proxy would simply have been incomprehensibly difficult to do without PCRE.

How easy would that be to do in BASIC with substr() calls, do you think?
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #5 on: January 04, 2011, 12:24:35 PM »
Quote from: Hattig;603742
Oh dear oh dear oh dear. This is a comment made out of pure ignorance.

Yeah, that raised an eyebrow here. Perl is a hideous language syntactically (though it is possible to write clean code, it's just that nobody ever does) but you have to give it it's dues; is there anything it can't do with text strings?
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #6 on: January 04, 2011, 09:50:36 PM »
Quote from: SamuraiCrow;603852
@Karlos and ChaosLord

TrueBasic does string slicing similar to what Python does so that may well be better than Perl or PHP at substring manipulations.

Unlikely. If there is anything that you can do to a string, literally anything at all, Perl already has 5 syntactically different ways to do it :lol: (at least 2 of which will be insanely optimized because someone thought the other three weren't up to the job, but each will also have subtle side effects to trip up the unwary developer).
« Last Edit: January 04, 2011, 10:01:51 PM by Karlos »
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #7 on: January 04, 2011, 10:00:09 PM »
Quote from: Franko;603863
(@ Karlos... don't you think it's way past time to take down the xmas banner... :))


But it's so cheerful and festive...
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #8 on: January 04, 2011, 11:44:39 PM »
Quote from: bloodline;603880
Just a quickie to suggest Objective-J :lol: (@karlos yeah, I've found another language I like)


I'm sure objective-c is at least as good as C/C++ for string manipulation, but no match for Perl in terms of what can be done per token.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #9 on: January 04, 2011, 11:59:58 PM »
Quote from: bloodline;603891
Not Objective-C... Objective-J ;)

Hmmm I'm not so familiar with pearl, but the GNUStep/Cocoa framworks are well serviced with a string object.


You said Objective-J but you were thinking Objective-C, otherwise you'd not have put the "@Karlos" ;)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #10 on: January 05, 2011, 12:27:49 AM »
Quote from: bloodline;603902
You have to check out Objective-j... It is to JavaScript what Objective-c is to c ;)

I think you'll loooooooove it :lol:

Hmmm... Really no JavaScript on A1200? I'm pretty sure the Amiga web browses support it!!


Javascript already has an object model, based on prototyping (rather than classes) and it's pretty easy to do reflective programming with it. Hard to see what it adds, other than objective-c syntax, which is not a selling point in the slightest.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #11 on: January 05, 2011, 01:11:29 AM »
Quote from: nicholas;603918
I'm phoning social services!


:roflmao:

Seriously, though, I bet they take a dim view of that sorta thing...
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #12 on: January 05, 2011, 10:48:00 AM »
Quote from: bloodline;603978
Karlos! Always thinking so low-level! Objective-J gives you access to the NeXTStep API in a web browser ;)

No, just thinking pragmatically.

All the implementations I saw turn your Obj-J into regular javascript. Hence there's nothing it can actually do that can't be done in JS directly. Probably with a greater degree of efficiency too.

There's nothing stopping your browser (and it's plugins) or any other javascript host application exposing any API it likes to javascript, irrespective of what language the API itself was written in. You don't need to change any syntax of JS for this. In fact, I can remember using and controlling java applets from javascript. You simply instantiate (or embed) the applet, get a DOM reference to it in JS, and then all the public methods of it are visible to javascript. All the webkit classes are written in C++ but you don't see someone creating a JS implementation of C++ to get at HTML5 ;)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #13 on: January 05, 2011, 10:50:29 AM »
@nik

Can you make your signature a bit bigger? I can't read it from street level... :lol:
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: creating a text adventure, but with what programming language?
« Reply #14 on: January 05, 2011, 11:33:26 AM »
Quote from: ejstans;603991
But Karlos, any Turing complete language can express another language. The original C++ compiler compiled into C code and yet it brought something new to the table, no? Hrm, right, there are plenty of C coders who disagree with that ("C can do OO just swell thank you, but OO is shite anyways")

Expressing C++ generics in C, without some hideous macro orgy (let's not forget, the preprocessor is not actually C) might test that theory in practise.

Anyway, my point was that JS already supports OO and Reflection, which are two paradigms that Objective-C supports as a language that you might want to exploit. As per your suggestion, "C with classes" brought a convenient OO syntax to C with support for classes, hierarchy and polymorphism. You can of course write object-oriented code in C, but the language syntax does not strictly support it or make it particularly convenient to write. The same claim can't be made for Obj-J; it doesn't bring any new paradigms to JS or make the existing ones easier to use (that could be subjective of course, some people don't like the prototype OO implementation of JS. Personally I'm sort of ambivalent about it). But you certainly don't need to do it to make host APIs easier to interface with.

Quote
Well then, let's try a different example! In the end, compiled languages usually come out in the form of cryptic assembly code, and certainly everyone can agree that being able to write in a high-level language is a welcome improvm....Oh right...This is the Amiga forum wherein this very thread there is talk of writing a text adventure in assembly...

Hmmm, what was my point again? :lol:

That pancakes rock :D
« Last Edit: January 05, 2011, 11:40:48 AM by Karlos »
int p; // A