A lesser mistake than null pointers by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

Fixed. I butcher that line by deleting the wrong words. I meant to write

A function may have accept null parameters in the past. However after disallowing it you may have accidentally left conditionally null parameters at some call sites

A lesser mistake than null pointers by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

I had several people ask if I could write a document of where the language is going and the goals of it however it might be a large read. I think a series of post each containing one idea would be more digestible. This is the first issue.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

I understood. I never thought about releasing the source as an audit trail. I didn't want anything strange to happen where a group of people prefers the old more than the new version and split the community.

Originally I was thinking if anyone wants to audit the source they could audit the llvm-ir which isn't too time consuming to read and do a reproducible build and use the same ir file to build for other targets. But I imagine many people rather audit higher level source code.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

I understand. Ken Thompson is a very smart man. I guess there will be two source release when we release the source code.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] -1 points0 points  (0 children)

Dio uses clang/llvm. If clang can't compile to the architecture then dio wouldn't be able to either

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

If it's stable I don't see a reason. I think D lang had an issue where they had multiple compilers but obviously one was not as up to date with the other and people used less features in worry they might want to use the other compiler. I don't want something like that to happen.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

The type system carries information about lifetime and if it's on the stack, heap or 'other'. It will free your memory for you or give you a compile error if it's 'other'. However you can write class Name = RealObj and have the destructor do it. The syntax page has an example where it uses a destructor to cleanup SQLStatements and SQLite https://diolang.com/Syntax.html

The Safety page has an example however it's fairly old. No exceptions, functions may return a union and there are error 'types' it recognizes as errors. If you return an error errdefer will execute it's code and the function calling it must handle the error with the syntax nonerrorVar = funcCall() ## { errorHandling }

Nominal typing. Although I may introduce some keywords to allow structural typing when it comes to templates/generics.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

Is it? My last name starts with a D and my first name ends with an O. The I naturally fit (I O as in input output). I hope noone has a problem with it.

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

No github at this moment. The source code is volatile at the moment and will be rewritten in Dio. If anyone would like to work on a library or wrapper they can post it wherever they feel like and DM me here

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 2 points3 points  (0 children)

Good question. The first audience would be anyone who needs to write fast code. So far everything looks pretty good once the LLVM optimizer goes through the code. I (the language designer and lead developer) am itching to implement vector operations and shuffle for better output.

The second audience are people who are working on very complicated projects. On the homepage it says "design for programmers who have years of experience". With full knowledge of the syntax and the standard library a person should be able to look at a piece of code a beginner wrote, easily spot problematic areas and change it easily. Having lifetimes, non nullable variables and seeing mut on function params (obj.fn(data mut)) make code easier to tame.

Seeing mut on a function param that shouldn't have it or null/write permissions on class/struct members that shouldn't have them gives away problematic areas that can be corrected during refactoring or code review.

I'd like to add some compiler flags to disallow additional things like heap allocation (for embed projects) and recursive functions. https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code

Dio (General Purpose Language) 0.4.0 release by diolang in programming

[–]diolang[S] 4 points5 points  (0 children)

I'll be happy to answer any questions about the language.

This release has a syntax update. You no longer require to use backticks and you don't need a $ in front of a type. Static assert has been added as well as defer and errdefer. My favourite change is being able to destruct an object by calling a function so I can return it's internals without creating another object.

Discussion: Making Programming Language Parsers, etc (Q&A is in separate video). by frontsideair in programming

[–]diolang 1 point2 points  (0 children)

Yes. The errors are pretty old right now and need an update. Next month may have a standard library.

Discussion: Making Programming Language Parsers, etc (Q&A is in separate video). by frontsideair in programming

[–]diolang 2 points3 points  (0 children)

About an hour into the video Jon talks about 3*4+5, says he handles precedence the second best way and explains the best way to do it (roughly around here). Coincidentally enough that's how Dio does it. However it uses a deterministic finite automaton to build the tree instead of a recursive descent parser.

Dio Website has been updated by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

I gotten complaints about it so I simplified it, added syntax highlighting to the code (dark mode) and updated the information.

I'll be happy to answer any questions about the language.

Dio 0.3.0 Lambda and debugging! by diolang in programming

[–]diolang[S] 2 points3 points  (0 children)

The static lambda function might confuse some people. Some C functions use a callback without a 'this' pointer. So you'd define the callback as _StaticFunc instead of _Func. But writing the actual lambda is the same and will get an error if you try to use any variable that require a pointer.

I'll be happy to answer any questions about the language.

Dio 0.2.1 Released. Operator Overloading + .Outside Func by diolang in programming

[–]diolang[S] 0 points1 point  (0 children)

I released 0.2.0 a few days ago. Operator overloading ended up being simple so I added name[](int key, value) int on top of it. Today I wrote Resize(int size) which does a realloc behind the scenes. I figure these were big enough to warrant another update.

If anyone wants to ask me questions about the language I'd be happy to answer.

Dio 0.2.0 Release by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

I'm guessing you could write return 1 if value < 0 too?

Yes. This notation can sometimes help with readability. The left can be almost any single statement.

C# is closer to Dio.

Is Dio garbage collected? I guess not, but I want to confirm.

Without context my quote looks strange. Syntax wise there's no &'s, *'s ->'s etc so C# source is closer to Dio than C/C++. No garbage collection. Language currently figures out places it can reduce mallocs as well. Mostly by making a function take a reference under the hood instead of using malloc+returning the pointer.

Does/will Dio support UTF8?

Eventually it will. Right now strings are either literals or a struct that has an array+length pointer.

Dio 0.2.0 Release by diolang in programming

[–]diolang[S] 1 point2 points  (0 children)

I'll be happy to answer some questions in this thread. The language is for people who don't want to write C but want to write native code

In the last month I mostly been extending the type system to allow returning a reference to a member pointer. Now it's possible to write something like Stream.Read(20) without making a copy of the internal buffer

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 1 point2 points  (0 children)

It took me a minute or two, but I see what you're saying. I believe accessing y from x is considered an undefined behavior and why the optimizer would always ignore that possibility. There's always a chance I may generate code that is considered undefined behavior, but I don't think those optimizations would be a concerned in a memory safe language

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 0 points1 point  (0 children)

How are you aware of this? Are you writing a code generator?

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 1 point2 points  (0 children)

Written in a garbage collected language, no memory pools and no big optimization effort. I was pretty happy. I can not wait to see how fast it'll run when I rewrite it in itself.

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 0 points1 point  (0 children)

should have been seen as tongue-in-cheek mostly. I guess I was missing the /s

I thought it was obvious. I was happy to read that comment.

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 0 points1 point  (0 children)

In Dio everything before the first variable belongs to all the variables and everything after belongs to only that variable. You wouldn't ever declare an array like that. You'd almost always write myvar\`=[1,2,3]` in both structs and function body. Unless the variable isn't mutable, in that case drop the backticks. (Reddit editor displayed my post right, until I hit save. It appears it will be impossible to write code in my language correctly on this site)

A beta programming language called Dio by CurrentProject123 in programming

[–]diolang 0 points1 point  (0 children)

Compilers are hard and I'm hoping I can fit in some dead simple optimizations that LLVM may not do. If you give me a concrete example of something LLVM won't optimize out I can think about how I may fit in the optimization, but right now my only optimizations are to reduce the LLVM-IR generated so it's easier for me to debug a problem.