Jump to content

I'm looking for a programming languege like this

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
alan

alan

    Newbie

  • Members
  • Pip
  • 4 posts
I'm looking for a programming language. I want it to work as much like this as possible.



Type information shouldn't need specifying unless something is being created, not on any part of being passed, for example like this.

func2(val)
{
  int n = 2;
  n += val;
  return n;
}

not like this.

int func2(int val)
{
  int n = 2;
  n += val;
  return n;
}


Any function should be able to be in any form, for example if the two functions exist + and PLUS then all these should be valid.

2 + 2
2.+(2)
+(2, 2)
(+, 2, 2)

2 PLUS 2
2.PLUS(2)
PLUS(2, 2)
(PLUS, 2, 2)


When creating something it should be a java like pointer to object, members should also seem separate like this.

obj a; // made a pointer called "a", members of "a" now appear to be pointer members and a few members that all objects get on creation
a.add_members(std::string); // gets all the default stuff from std::string
a = "apple";
a.add_members(std::string::spellcheck) // gets a specific thing not included as default from std::string
a.spelled_correctly() // this line returns a bool
a.remove_members("=", std::string::speellcheck)
a = "bcd"; // error

Because construction might have a few steps in many cases it could often occur in functions like so.

number(16, 2) // a 16 bit number with 2 decimal places
set("LL") // a set where each element can be anything stored as a linked list

internally, the function set("LL") could do something like this

obj a;
a.add_members(std::set);
switch (param("storege_type"),
("LL",
a.add_members(std::set::storage::linked_list)
)


Function shouldn't require brackets at the end if they are being given no parameters.


Also, lets think about quotes, the function.

a.spelled_correctly

could be

a."spelled correctly ?"

similarly here

2 "+" 2
2."+"(2)
"+"(2, 2)
("+", 2, 2)

However this is a bit verbose, it's helpful though if we want to pass the functions name around as a parameter to think of there names as being like a string.


A program that looks like this in C++

void func1()
{
this();
that();
other();
}

void func2()
{
std::cout<<"abc";
func1();
}

int main()
{
func1();
func2();
return 0;
}

could be better represented like this

obj func,
func1 = {this, that, other},
func2 = {std::cout<<"abc", func1},
// func2.unordered,
// func2.scope_behavior_global,
func1.run(),
func2.run_any_order(),
return 0


Using design created in this sort of way things could occur such as sets could be asked things using there members like "compare each of your contents that match these requirements against each other using this member and return to me this sort of information" using a fairly small fairly human readable function.

#2
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
You could always write your own programming language.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are several loosely typed languages. VBscript and JavaScript come to mind.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
alan

alan

    Newbie

  • Members
  • Pip
  • 4 posts
I'm not keen on VB stuff, Javascript (and aparently PHP is nice too) is too slow and intended for web programming.

LUA looks nice, how fast is it? How practical would it be to create software such as an application or game using it instead of using it for scripting within one of thease enviroments?

I can't think of a way to write my own that dosn't involve knowing Machine code\Assembly and a lot of other things to a verry high level or having some C++ code for example read a text file, which would be quite slow, or at least much slower than C++ is.

I could write up my design but I may never know if it covered all the sorts of things a perspective implementor would need to know. I don't know if I would get started with no support though.

#5
JCoder

JCoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 245 posts
Scala looks quite similarly to this and it is blazingly fast compared to Python, Ruby or Lua.
In Scala you can create your own DSLs, so you can adapt language to your needs easily.
And you can pass functions as arguments of another functions and many, many more.

#6
alan

alan

    Newbie

  • Members
  • Pip
  • 4 posts
Looks interesting. Whats a DLS?

Can you show examples that do the sort of things my examples in the first post do?

I looked at there website, there do apear to be times when type information is input at a time when nothing is being created, and looking on the Wiki it talks about inheritance and the such, which shouldn't be needed in a modular aproach. The syntax looks verry complex although this is not neccerally a bad thing.

#7
JCoder

JCoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 245 posts
DSL = Domain Specific Language.
Type information is a good thing. It improves readability, enables to catch many bugs and enables the program to run many times faster than typical dynamically typed scripting language.
Additionally Scala's type system requires only very little type information to be specified.
The syntax is much simpler and consistent than the one you propose. What you propose is indeed quite complex. I would never like to program in a language where you are allowed to misspell function names.

2 + 2
2.+(2)
+(2, 2)
(+, 2, 2)
First two run out-of-the-box. Third can be easily done by providing a global object with a 2-argument "+" method and importing it.
Fourth is LISP-style, not readable, don't know why anyone would need it in a language with infix operators.

However, you can simulate it with something like:
(_+_, 2, 2).evaluate
and some implicit conversion from the Tuple3 trait. So as you can see, Scala has quite flexible syntax (and much of it is accomplished by libraries, not the compiler).

#8
keller

keller

    Learning Programmer

  • Members
  • PipPipPip
  • 38 posts
You can do this in Scheme. You have to create a parser and abstract datatypes, but it wouldn't be that hard.

#9
alan

alan

    Newbie

  • Members
  • Pip
  • 4 posts
Thanks for introducing me to Scheme. I like some aspects of how it works a lot. I wrote some code.

(define (sqradd x y) (+ (sqr x)(sqr y)))
(define (pythagoras x y) (sqrt (sqradd x y)))
(define (xnor a b) (or (nor a b)(and a b)))
(define funcs (list sqradd pythagoras (list "abc" xnor)))
(print (list-ref (list-ref funcs 2)0))

I'm a little confused about how you pass by referance and what Let is all about. The default appears to annoyingly be like by copy. I'm still only just starting to learn it though.