Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 06:38:16 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 270 271 [272] 273 274 ... 279
Print
Author Topic: The happy programmer room  (Read 678504 times)
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5420 on: March 15, 2019, 06:14:34 PM »

I started work on a small programming language as a side project. It's nothing fancy, and isn't even functional yet, but it has been a pretty good exercise in how to make my own lexer, parser, and visitor. Next up is going to be the interpreter so I can actually make it do stuff :D

Here's a github link of course: https://github.com/MiguelArseneault/ndl

ndl stands for "Non-Descript Language", which I think illustrates my infinite wisdom and latent intelligence quite well.
Logged

Crimsontide
Level 5
*****


View Profile
« Reply #5421 on: March 15, 2019, 07:48:18 PM »

I started work on a small programming language as a side project. It's nothing fancy, and isn't even functional yet, but it has been a pretty good exercise in how to make my own lexer, parser, and visitor. Next up is going to be the interpreter so I can actually make it do stuff :D

Here's a github link of course: https://github.com/MiguelArseneault/ndl

ndl stands for "Non-Descript Language", which I think illustrates my infinite wisdom and latent intelligence quite well.

Cool stuff Smiley
Logged
oahda
Level 10
*****



View Profile
« Reply #5422 on: March 16, 2019, 01:26:15 AM »

slurpFile() Huh?
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5423 on: March 16, 2019, 05:02:18 AM »

In my defense, it’s a term I saw someone else use and not something I came up with Tongue
Logged

kason.xiv
Level 0
***


View Profile
« Reply #5424 on: March 16, 2019, 02:18:45 PM »

I started work on a small programming language as a side project. It's nothing fancy, and isn't even functional yet, but it has been a pretty good exercise in how to make my own lexer, parser, and visitor. Next up is going to be the interpreter so I can actually make it do stuff :D

Here's a github link of course: https://github.com/MiguelArseneault/ndl

ndl stands for "Non-Descript Language", which I think illustrates my infinite wisdom and latent intelligence quite well.

That's wicked man, always a monumental undertaking.

A little suggestion, it would be great to have a readme at the top level that describes how the language works, syntax, keywords, grammar, etc.
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5425 on: March 16, 2019, 02:25:23 PM »

I agree, and I’ll do that as soon as it’s set in stone and functional!
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5426 on: March 18, 2019, 08:40:06 PM »

Updated again. I made an interpreter that can almost actually do stuff, and I wrote up a basic readme with the basic design goals of the language. I also changed the repository's structure to be at the root of the project itself instead of the workspace.

Here's the link again!
Logged

Daid
Level 3
***



View Profile
« Reply #5427 on: March 19, 2019, 01:54:42 PM »

Quote
More seriously, the main problem people have with this way of doing this is that mixing tabs and spaces leads to disaster. To fix this, one would have the ability to specify the length of a tab in spaces somewhere in the file's header, that way every editor would be able to display that file correctly. Again, no idea if this is actually a good idea, but this whole thing is an experiment after all.
Python3 fixed this by saying indentation should be spaces or tabs, but never mixed, which is a syntax exception now.
Logged

Software engineer by trade. Game development by hobby.
The Tribute Of Legends Devlog Co-op zelda.
EmptyEpsilon Free Co-op multiplayer spaceship simulator
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5428 on: March 19, 2019, 02:15:16 PM »

Yes, and it's also an arbitrary restriction which, as I've stated in the readme, is something I want to avoid if possible. Plus, the issue with that rule is that it's impossible to visually distinguish lines from spaces, so you end up with frustrating moments where a script won't work and you have to find the spot where someone used spaces instead of tabs. My take is that it should work if it lines up on your monitor, at the cost of having to specify how you want them to line up.
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5429 on: March 20, 2019, 01:57:50 PM »

I made some more progress on my language thingie. You can actually run code now, declare variables and initialize them, print text, check if two variables are equal and use functions as unary and binary operators everywhere.

There's a bunch more you can't do though, such as using loops, using more than the two built-in functions, and although there appears to be code for it, you can't actually declare your own functions yet as calling them doesn't work right at the moment. You also can't assign new values to variables after having created them, which yes, makes them 100% useless as variables.

You can see the progress on ndl here!

(oh, and you have to run all this code manually since the repo doesn't include a project file)
Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #5430 on: March 22, 2019, 01:46:17 AM »

I never tried to write a programming language myself. What are the reasons that keeps you interested in doing it?
Logged

Games:

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5431 on: March 22, 2019, 04:12:45 AM »

I've attempted to make programming languages before, and I lost interest for each one because I would always get discouraged at the huge time investment it would take to make them useful. This time around I'm just making it for fun and as an experiment, which seems to fuel my motivation for it.

So yeah, I'm just making a programming language for fun.

Logged

qMopey
Level 6
*


View Profile WWW
« Reply #5432 on: March 22, 2019, 08:18:46 AM »

Doing quite well implementing net support for my project! Using libsodium for crypto and auth, and so far its an absolute breeze. libsodium is super high quality - only nice things to say. It is very difficult to mess it up due to their high level and straightforward API.
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5433 on: March 22, 2019, 03:15:33 PM »

Nice! Is the documentation as high quality? Would you say it's better or worse than, say, SDL's documentation wiki?



I did some more work on ndl today, implementing while loops, comments, mathematical operators and proper assignment statements. As usual, changes are on GitHub. Also, I forgot to write about ndl's syntax, so I'll explain it here!

General

ndl is a language where there are as little syntactical support symbols as possible. this means no parentheses around if or while statements, no semicolons, indentation determines scope, and all functions with the right argument count can be used as unary and binary operators.

Variables

Code:
name Type = value

Variables, like all other declarations with names, start with their name, then specify their type and finally assign an optional initial value. I plan on making the type optional as well.

Ifs/Whiles

Code:
if condition
    statements...

while condition
    statements...

If statements are composed of the "if" keyword followed by an expression with a boolean type and a series of statements indented one level higher than the if itself. The exact same principle applies to while loops.

Function Calls

Code:
// normal function call form
some_function(arg1,...)

// unary operator form
some_function argument

// binary operator form
arg1 some_function arg2

Any function that takes one argument may be called as if it was a unary prefix operator (think of the way you put a minus sign in front of a number to negate it). If a function takes two, then it can be used in the same way one would use an addition or multiplication operator. Of course, functions may also simply be called in their usual form with parentheses and comma-separated arguments.

Comments

Code:
// line comment
/*
    multiline comment
*/
/*
    /*
        nested multiline comment!
    */
*/

Finally, of course, you can use comments. A cool thing about the last one though is that you can nest multiline comments, allowing you to surround regions of code which already contain comments without causing issues where the first */ encountered ends the comment unexpectedly.

I think that's it. It's starting to look like an actual language now at last, althought there are still many rough edges and the implementation is a bit flimsy as far as error checking is concerned.

Still, nested comments are a feature that several major language still do not have, so I'm quite happy about having implemented them!
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5434 on: March 22, 2019, 06:27:37 PM »

Hey I've been reading over the readme for ndl and came across this part :

Quote
A little syntax trick nabbed from D and expanded upon. The idea in D is that any function can be called as a member function with dot notation, and the variable before the dot is used as the first argument. Furthermore, functions that would normally required empty parentheses can simply ommit them so that those look like you're accessing a member variable. The way I'm boosting this idea is that you can also call functions that have one or two arguments as unary or binary operators. In fact, a function of any nonzero number of arguments can be called this way by chaining the function name between that number of arguments. Will this create problems with how the language parses expressions? Probably. Hopefully! :D

That member function thing is cool!

The remove of parentheses I do have a question : If the return type is void are you forced to use the parentheses? If not then if you had a mutating function with a void return type would it look like this : ?
Code:
// some code inside a member function
thingThatMutatesButDoesNotReturnAnything; // Does this work?
// some more code

Maybe it's just lack of exposure but that line tends to look a bit confusing to me if it's valid.
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #5435 on: March 22, 2019, 07:10:14 PM »

Yeah, you could do that (minus the semicolon since that's not a thing in ndl) and it probably would be confusing for someone who's used to functions calls always having parentheses. It shouldn't be too hard to get accustomed to though, since functions tend to be named after verbs, so you could still tell what's a variable and what's a function at a glance by paying attention to the naming convention.

If it causes significant problems for anyone though, they can still use the old notation style and it would work. The idea is that you have the choice to do whatever you like for calling functions!
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5436 on: March 22, 2019, 07:33:54 PM »

I guess the thing is I am used to it from my experiences with functional languages but functional languages are usually pure so void return functions are extremely rare and pointless and in some languages impossible.

I can adapt Smiley
Logged

Crimsontide
Level 5
*****


View Profile
« Reply #5437 on: March 22, 2019, 08:05:31 PM »

I guess the thing is I am used to it from my experiences with functional languages but functional languages are usually pure so void return functions are extremely rare and pointless and in some languages impossible.

I can adapt Smiley

I'm having flashbacks of Miranda form uni... I hate functional languages (not trying to imply your language is bad in any way ProgramGamer).
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5438 on: March 22, 2019, 09:24:04 PM »

I guess the thing is I am used to it from my experiences with functional languages but functional languages are usually pure so void return functions are extremely rare and pointless and in some languages impossible.

I can adapt Smiley

I'm having flashbacks of Miranda form uni... I hate functional languages (not trying to imply your language is bad in any way ProgramGamer).

Haha, I never went to university and am only now discovering F# which from my understanding is essentially Miranda for .NET and I am loving it. Not for video games or anything real time but I love how functions and values have no difference. I can replace a value with a function that returns the same type of value easily. Also discriminated unions with matches are something I miss sorely.

Of course I'm in the romance period, for me it feels like learning to program again. I'm sure I'll be brought back down to earth eventually.
« Last Edit: March 22, 2019, 10:27:50 PM by InfiniteStateMachine » Logged

pelle
Level 2
**



View Profile WWW
« Reply #5439 on: March 23, 2019, 01:55:58 AM »

In my defense, it’s a term I saw someone else use and not something I came up with Tongue

Clojure has a slurp function that is very convenient. Just pass it a filename or URL.

https://clojuredocs.org/clojure.core/slurp
Logged
Pages: 1 ... 270 271 [272] 273 274 ... 279
Print
Jump to:  

Theme orange-lt created by panic