Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Introducing a programming language called TYL

tyllang

New Coder
Tyl Programming Language 2.2 released!


Tyl (pronounced TEEL) is a general-purpose programming language that is intended for intermediate and experienced programmers, as well as, for totally beginners.


Some of Tyl features:

• Clean code
• Symbolized keywords
• Modularity
• Dynamic program structure
• One line statements
• System modules & functions
• Multiple variables declaration
• Automatic type inference
• Internal framework


Tyl Software includes the following modules:

• Tyl Scanner
• Tyl Parser
• Tyl Statement Generator
• Tyl Runtime
• Tyl Launcher
• Tyl Runner
• Web Files Generator & Automation


Here is an example of a database project. It is composed of three programs in Tyl:

program: geodb.create.tyl
____________________________________________________________________________________________________

! =========== GEODB SETUP (MS SQL) ===========
!
! To setup geodb database, first run geodb.create.tyl,
! then run geodb.build.tyl
! To check if geodb database and tables were created
! successfully, run geodb.show.tyl


! set dropdb variable to determine whether to delete and
! create geodb database.
! if false and geodb database exists, only countries and
! mountains tables will be dropped
dropdb \t

dbexistcmd 'select count(*) from sys.databases where name=`geodb`'

tablesexistcmd 'SELECT count(*) FROM geodb.INFORMATION_SCHEMA.TABLES '
tablesexistcmd ++ 'WHERE TABLE_TYPE = `BASE TABLE` '
tablesexistcmd ++ 'AND (TABLE_NAME = `countries` OR TABLE_NAME = `mountains`)'


! perform 'clean' connection, in order to handle databases
mssqldb 'data source=(LocalDb)\MSSQLLocalDB;integrated security=true;connection timeout=60;'
mssqldb.connect

! if geodb database does not exist, force db drop
result mssqldb.value dbexistcmd
not result ? dropdb \t

dropdb ?
print 'dropping database `geodb`...'
mssqldb.execute 'DROP DATABASE geodb'

~
pause 1
result mssqldb.value dbexistcmd
not result ? %
^
print 'dropped ok.' + newline

print 'creating database `geodb`...'
mssqldb.execute 'CREATE DATABASE geodb;'

~
pause 1
result mssqldb.value dbexistcmd
result ? %
^
print 'created ok.' + newline
^

mssqldb.sqlerror ? print mssqldb.sqlerror


! connect to geodb database
mssqldb 'data source=(LocalDb)\MSSQLLocalDB;initial catalog=geodb;integrated security=true;connection timeout=60;'
mssqldb.connect

not dropdb ?
print 'dropping tables: `mountains`, `countries`...'
mssqldb.execute 'DROP TABLE mountains; DROP TABLE countries;'

~
pause 1
num mssqldb.value tablesexistcmd
not num ? %
^
print 'dropped ok.' + newline
^

mssqldb.sqlerror ? print mssqldb.sqlerror


! ATTENTION: MS SQL accepts only apostrophe symbols ('), as
! quotation marks. Do replace all apostrophe
! symbols with backtick symbols (`).

cmd ''
cmd ++ 'CREATE TABLE [dbo].[countries] ('
cmd ++ ' [id] INT IDENTITY (1, 1) NOT NULL,'
cmd ++ ' [name] NVARCHAR (20) DEFAULT (``) NOT NULL,'
cmd ++ ' PRIMARY KEY CLUSTERED ([id] ASC)'
cmd ++ ');'

cmd ++ 'CREATE TABLE [dbo].[mountains] ('
cmd ++ ' [id] INT IDENTITY (1, 1) NOT NULL,'
cmd ++ ' [name] NVARCHAR (20) DEFAULT (``) NOT NULL,'
cmd ++ ' [country] INT NOT NULL,'
cmd ++ ' [height] INT NOT NULL,'
cmd ++ ' PRIMARY KEY CLUSTERED ([id] ASC),'
cmd ++ ' CONSTRAINT [FK_mountains_countries] FOREIGN KEY ([country]) REFERENCES [dbo].[countries] ([id])'
cmd ++ ');'

mssqldb.execute cmd
pause 1

num mssqldb.value tablesexistcmd

num 2 ?
print 'tables created successfully.'
\
print 'tables creation failed!' + newline
print mssqldb.sqlerror
^




program: geodb.build.tyl
____________________________________________________________________________________________________

countries 'Chile' 'Japan' 'Russia' 'Tanzania' 'Tibet'
mountains 'Villarrica' 'Fuji' 'Elbrus' 'Kilimanjaro' 'Chomolungma' 'Kita' 'Llullaillaco'
mcinds 0 1 2 3 4 1 0
heights 2860 3776 5642 5895 8848 3193 6739
countrieslen len countries
mountainslen len mountains
rowsinserted 0

mssqldb 'data source=(LocalDb)\MSSQLLocalDB;initial catalog=geodb;integrated security=true;connection timeout=60;'
mssqldb.connect

! ATTENTION: MsSql accepts only apostrophe symbols ('), as
! quotation marks. Do replace all apostrophe
! symbols with backtick symbols (`).


! clear DB tables
mssqldb.execute 'delete from mountains; delete from countries;'
pause 0.2

! ensure tables are clear
countriesnum mssqldb.value 'select count(*) from countries'
mountainsnum mssqldb.value 'select count(*) from mountains'
num countriesnum + mountainsnum
num 0 ?
print 'countries and mountains tables cleared successfully.'
\
print mssqldb.sqlerror
pause 3
exit
^

! build countries table
rowsinserted 0
countries c ~
cmd 'insert countries (name) values (`' + c + '`)'
mssqldb.execute cmd ? rowsinserted ++ \ %
^

! if not all rows inserted, print the last SQL error
rowsinserted < countrieslen ? print mssqldb.sqlerror

print rowsinserted + ' rows inserted to countries database'

! exit if no row inserted
rowsinserted 0 ?
pause 3
exit
^

! build mountains table
cids mssqldb.list 'select id from countries'

rowsnum mountainslen
rowsinserted 0

i rowsnum ~
mcind mcinds i
cid cids mcind

cmd 'insert mountains (name, country, height) values ('
cmd ++ '`' + mountains i
cmd ++ '`, ' + cid
cmd ++ ', ' + heights i
cmd ++ ')'

mssqldb.execute cmd ? rowsinserted ++ \ %
^

! if not all rows inserted, print the last SQL error
rowsinserted < rowsnum ? print mssqldb.sqlerror

print rowsinserted + ' rows inserted to mountains mssqldb'




program: geodb.show.tyl
____________________________________________________________________________________________________

mssqldb 'data source=(LocalDb)\MSSQLLocalDB;initial catalog=geodb;integrated security=true;connection timeout=60;'
mssqldb.connect

! declare records that will be used for
! countries and mountains rows that are
! fetched from geodb database

! country record items will be accessed indirectly
c { }
! mountain record is declared with all expected keys,
! and items can be accessed directly (dot-notation).
! cname key is declared for use in method 3
m { id 0, name '', height 0, country 0, cname '' }

print 'countries' + newline + '--------------------'
countries mssqldb.all 'select * from countries'
cmax len countries
ci cmax ~
c countries ci
text c 'id'
text ++ ': ' + c 'name'
print text



≡ method 1 demonstrates how to search data in referenced table
≡ using the countries list.
≡ for direct approach use method 3
print
print 'mountains (method 1)' + newline + '--------------------'
mountains mssqldb.all 'select * from mountains'
mmax len mountains
mi mmax ~
m mountains mi
text m.id
text ++ ': ' + m.name
text ++ ' (' + m.height
text ++ '), '

≡ search country name by id
mcid m.country
cname ''
ci cmax ~
c countries ci
cid c 'id'
cid mcid ? ✖ cname c 'name'


print text + cname


≡ method 2 demonstrates how to search data in referenced table
≡ using countries record that is built from countries list.
print
print 'mountains (method 2)' + newline + '--------------------'

countriesrecord { }
ci cmax ~
c countries ci
k c 'id'
v c 'name'
countriesrecord <- k v


mountains mssqldb.all 'select * from mountains'
mi mmax ~
m mountains mi

≡ get country name from countries record by
≡ mountain country id
cid m.country
cname countriesrecord cid

text m.id
text ++ ': ' + m.name
text ++ ' (' + m.height
text ++ 'm), ' + cname

print text



≡ method 3 uses SQL statement that gets the referenced data
≡ by joining the two tables
print
print 'mountains (method 3)' + newline + '--------------------'

cmd ''
cmd ++ 'select m.id, m.name, m.height, c.name cname '
cmd ++ 'from mountains m join countries c '
cmd ++ 'on m.country=c.id '
cmd ++ 'order by m.id'

mountains mssqldb.all cmd
mi mmax ~
m mountains mi
text m.id
text ++ ': ' + m.name
text ++ ' (' + m.height
text ++ '), ' + m.cname
print text




More details about the programming language at tyl-lang [DOT] dev
I'll appreciate too any critical advice and also technical proposals regarding the language usability.
 
Honestly it just feels like a bit of an expansion over shell/batch.
Are there any plans to allow extending of the language with custom modules?
 
Honestly it just feels like a bit of an expansion over shell/batch.
Are there any plans to allow extending of the language with custom modules?
Based on looking at the second half of the post that is composed entirely of code, it seems like it's more of an SQL-like language(or something that is meant to be an extension to SQL). It's not even formatted with BBCode so I already don't like the look of the language.

Confusing statements too like:
Clean code
Code:
≡ search country name by id
mcid m.country
cname ''
ci cmax ~
c countries ci
cid c 'id'
cid mcid ? ✖ cname c 'name'
This is fine.
 
it seems like it's more of an SQL-like language(or something that is meant to be an extension to SQL).
Yeah, the website seems to have some examples past database-handling but for the most part this feels a lot like a difficult to read version of Lua. Not sure how to feel about it.
 
Yeah, the website seems to have some examples past database-handling but for the most part this feels a lot like a difficult to read version of Lua. Not sure how to feel about it.
I didn't see where you got the Lua from, but looking at the site there, I can see now. It seems to have mashed Lua and Batch/Bash horribly together to help work with SQL. I'm actually thinking it's trying to be like Perl now.

Honestly, we have enough programming languages in the world that can do all sorts of jobs - including scripting tasks for databases. Why do we need this?
 
TYL is a combination of programming languages ideas, and also has its unique design and coding paradigm. It was developed in the last years and sure to give developers coding abilities.

As to bringing it closer to OOP, the plan is to have it in within two years, but as it is yet another kind of tackle it will take its design and development time.
A step in this direction were the so called Dynamic Modules, that currently are used for a predefined programming tasks.

I had it before with coders on forums that without trying the language are throwing conjectures and instant judgements, so I welcome people who want to tackle the language with programming tasks and have their opinion based on real action. Needless to say that for development purposes a lot of coding was done during last years that rigorously validated the strengths of TYL.
 
Good point about SHELL/BASH. As TYL tries to achieve programming tasks without braces symbols, it mimics these scripting languages. But to those who are familiar with SHELL/BASH, TYL is easier to work with and have good code flow mechanisms.

About why it is needed. Well there are thousands of speaking languages, and yet most of the world also speaks English. So if people will do find that TYL helps them achieve their programming goals, so be it.
 
I'm a bit late to the discussion. Assuming you're still here, my 2 cents. Really, there are more than enough languages already. No one is perfect for everybody of course, each have their own merits and flaws. Introducing yet another one, combining features of other languages, make the landscape even more confusing. You seem to think that all of these, even Python, are unsuitable for beginners ? I don't see how e.g. disposing of the if and then keywords makes things easier for beginners. Or cryptic code like this ?
mountains mssqldb.all cmd
mi mmax ~
m mountains mi
You seem a bit miffed by the fact that people on forums have an opinion about your language without trying it out. But wasn't this to be expected ? Experienced programmers will have made their choice(s) already, and beginners will wisely pick something established that many people will be able to help them with. Neither are likely to spend time investigating something new just out of curiosity or the wish to learn yet another language.
 
Last edited by a moderator:
Back
Top Bottom