Monkey programming for dummies

Monkey Forums/Monkey Programming/Monkey programming for dummies

Gary Leeds(Posted 2011) [#1]
Is there any plans to either rewrite the internal documentation or is someone writing a simplified guide that can be printed out?

I am sure Monkey is very powerful when you get to learn the commands but I am going through the current documentation creating a printable version and I come across examples like this

Module monkey.map

Introduction
The map module provides support for the map data structure.

A map is a container style object that provides a mechanism for associating key objects with value 
objects. This is done using Node objects that contains a reference to both a key and a value, along 
with information about the node's location within the map.

Each key in a map occurs exactly once - setting a key to a certain value overwrites any previous 
value that may have been asspociated with that key.

Maps are very efficient, and can handle inserting, removing and finding keys in 'O(log2)' time. That is, 
the time needed to insert, remove or find a key is proportional to log2 of the number of items in 
the map.


Now to me (and probably anyone else learning Monkey this is just total gibberish. It may well be the case that I would never need to use maps but as I don't even understand what they are or do I would never know. I am using maps as an example here, this is not an isolated example, there are other examples all the way through the docs.

Also there are very few actual code examples in the documentation. A few lines of code with the output of the code would go a long way to explain what a function actually does.

Speaking personally I would gladly pay for a "Monkey for Dummies" PDF guide I can print out and refer back to as and when I need it

Gary


Warpy(Posted 2011) [#2]
For maps, sets, stacks and so on, I think the documentation is bad because the implementation is unwieldy without interfaces. When we get interfaces in the next version, it should get a lot easier.


muddy_shoes(Posted 2011) [#3]
I'd ask to what extent you're looking for improvements to the language documentation and to what extent you're looking for something that explains the programming concepts being used. To put it another way: are you confused about the Monkey implementation of maps or are you just coming from a position where you've never heard of a map as a data structure?


JD0(Posted 2011) [#4]
That looks like a great description for a map to me.. I'm not sure I understand what the problem is.

I think more appropriately you want a data structure for dummies introduction.. you do need to know what a data structure is, what keys, and values are, what nodes are, and what big-O notation is to fully understand that example.

Those are basics for understanding data structures, and descriptions can be found all over the internet.. Wikipedia does a good job of explaining them.

You don't have to fully understand everything to know how to use it.


Gary Leeds(Posted 2011) [#5]
I am just using the map command as an example. First I have never heard of them so do not know if they would be useful to me.

The point I was trying to make was that the inbuilt help at times is confusing.

Another example

Method Replace
Syntax
Method Replace$( findString$, replaceString$ )

Parameters
findString, replaceString - string values.

Description
Replaces all occurances of findString with replaceString and returns the result.


Now I can see the basic concept of the command but where do I give it the string to look in? Does it work something like

string$ = "hello world"
string$ = Replace$( "hello", "goodbye" )
print (string$)

the console outputs goodbye world


Now I have no idea if that is how it works but the original help text gives no context in how the Replace$ should be used and this is repeated for many many commands in the help.

A few lines of example code goes a long way in showing how a command works rather than just a structured description.

Maybe it's just me and maybe Monkey is not for me at this moment in time


muddy_shoes(Posted 2011) [#6]
@Gary

Replace is a method on the string class, so the context for the call is the string you call it on:

Function Main()
	Local test:String = "hello world"
	test = test.Replace("hello", "goodbye")
	Print test 'prints "goodbye world"
End


It seems to me that you are unfamiliar with object orientation. The "Path of the Monkey" article briefly covers some parts of this but there are plenty of introductory tutorials on the Web. I would offer a recommendation but I don't know what languages you are familiar with, so I would be worried about pointing you to something that actually puts you off with more new syntax.


Gary Leeds(Posted 2011) [#7]
@muddy,

Now that makes total sense and thats the kind of thing I feel the command help file needs.

My background is in C but never had cause to use pointers and the like and also dabbled in php.

Thanks for your help and explanation