288 reputation
311
bio website
location
age
visits member for 2 years, 5 months
seen Dec 18 at 1:58

I'm the author of a natural language programming system called EngScript.

Some of my favorite software projects are:

I have written some useful macros in sweet.js:

//for repeating if statements
macro ifs{
    rule{
        {$($x {$y...}) ...}
    } => {

        $(if($x){
            $y...
        }) ...
    }
}

//a concise way to define several different functions
macro manyFuncs{
    rule{{$($x ($y...) {$z...}) ...}
    } => {
        $(function $x($y...){
            $z...
        }) ...
    }
}

ifs {
    a{
        b
    }
    c{
        d
    }
}

manyFuncs{
    fullName(firstName, lastName) {
        return firstName + lastName;
    }
    squared(a){
        return a*a;
    }
}

Right now, I'm searching for a parser that can handle ambiguous grammars.

In theory, it would also be possible to create a very concise programming language with implicitly defined parameters:

isDivisibleBy: (foo % bar) == 0
//This is a function with 2 parameters: foo and bar.

isEven: isDivisibleBy(foo, 2)

isOdd: !isEven(param1)

firstCharacter: theString[0]

lastCharacter: theString[theString.length - 1]

firstNCharacters: theString[0:end]

firstCharacterIsLastCharacter: firstCharacter(stringParameter) == lastCharacter(stringParameter)

printEach: for current in anArray{ print current }

http://rosettacode.org/ is one of the most comprehensive programming language references I've ever found.

Optionally-typed programming languages are really awesome: they combine the type safety of languages like Java with the conciseness of languages like Python.

Some cool things that I've made:

Someday, I hope it will be possible to create a programming language that mixes code from different languages into a single file, like this:

Python {
    def foo():
        return "foo"
}
Ruby {
    def bar
        return foo + " was called from Python."
    end
}

Aug
19
comment One language to rule them all? (Them being platforms.)
See the answers to this question: How can I write a set of functions that can be invoked from (almost) any programming language?
May
12
comment Why aren't there automated translators from one programming language to another?
Also, Wikipedia has a fairly extensive list of automatic programming language translators.
Feb
5
comment The most human language like programming language
EngScript is the most English-like programming language I've seen so far: let y be 3; set x to 2; print{the sum of (x to the power of 3) and 4} is actually valid EngScript code.
Jan
16
comment The most human language like programming language
xTalk is another notable family of structured-English programming languages.
Apr
15
comment programming an expert system
What specific problem is the expert system intended to solve?
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
To solve this problem, I'd probably need to represent arrays as JSON strings, and then write conversion functions to convert the strings to string arrays in each language. Fortunately, there are already some libraries for this purpose: google.com/…
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
If that's the case, then would I be better off manually porting an entire API (possibly with 200 different functions) into 8 different languages, instead of writing a single API that is syntactically valid in all of these languages (which would depend on just 10 or 20 language-specific functions in each language)?
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
@mortalapeman It wouldn't be necessary to implement a completely new programming language. Instead, I could simply use a restricted subset of an existing programming language (such as Java) instead of creating a completely new language. To keep things simple, I'd also need to use a single data type as the input and output of every function. So String[] theStr = ["Hi!"] in Java would become var theStr = ["Hi!"] in JavaScript.
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
@mortalapeman Each "polyglot" function would only depend on a small number of "language-specific" functions. As soon as I had written a few "language-specific" functions for a particular language, I would be able to port a large number of "polyglot" functions to that language with only a few minor semantic changes.
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
@ipaul In C, I would implement printSomething as printf(thingToPrint). In Java, it would be System.out.println(thingToPrint). In Ruby, it would be puts(thingToPrint).
Mar
18
comment Writing an API that is syntactically valid in multiple programming languages
@ipaul I'm trying to write an API that will be compatible with as many programming languages as possible. Of course, it would be necessary to write a few "language-specific" functions to handle if-statments and while-loops, and then write an entire function for the body of each while-loop and if-statement.
Dec
13
comment How can I write a set of functions that can be invoked from (almost) any programming language?
In order to use a command-line interface in this way, would you get the console output for a specific command (such as whoami on Ubuntu to get the username), or did you have something else in mind?
Nov
23
comment How can I write a set of functions that can be invoked from (almost) any programming language?
I recently found a programming language called Haxe- it can be compiled to many different programming language, and appears to be extremely well suited to this purpose.
Oct
20
comment Is javascript worth learning if you do not plan on being a web developer?
@VitorBraga I think developing applications with node.js would be one good option - it has a comprehensive set of libraries that are useful for general-purpose scripting tasks such as image editing and file reading/writing.
Oct
20
comment Is javascript worth learning if you do not plan on being a web developer?
@dkuntz2 Javascript isn't just good for "web stuff" - I use node.js as a general purpose scripting tool, and for developing desktop applications.
Sep
3
comment How can I write a set of functions that can be invoked from (almost) any programming language?
How can foreign function calls be done using Apache Thrift?
Aug
2
comment Is it possible to call a Javascript function from C?
I'm trying to make the Javascript API accessible from as many programming languages as possible for the purpose of code reuse. One method of doing this is by writing a C API, as described here: programmers.stackexchange.com/a/157605/57752
Aug
2
comment Is it possible to call a Javascript function from C?
Also, I'd like it to be cross-platform.
Aug
2
comment Is it possible to call a Javascript function from C?
I'm aiming for code reuse, not browser automation.
Aug
2
comment Is it possible to call a Javascript function from C?
There are a few Javascript-to-C++ bindings available, but I need my Javascript functions to be invoked from C, not C++.