Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"babel-plugin-transform-do-expressions",
"babel-plugin-transform-function-bind",
"babel-plugin-transform-export-extensions",
"babel-plugin-transform-object-rest-spread"
"babel-plugin-transform-object-rest-spread",
["babel-plugin-transform-builtin-extend", {
globals: ["Error"]
}]
],
"presets": [
"react",
Expand Down
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
</p>
</p>

VSL is a modern, powerful, fast, and easy to write programming language designed
for the 21st century.


## Download

You can either build from source (see Building) or installed a pre-compiled
Expand Down Expand Up @@ -87,24 +91,31 @@ one _wants_ from a programming language:
- Bare-metal speed (yeah...)
- Powerful and close-to-hardware (JS, Python, and Java lack)

So VSL aims to solve _all_ of these problems. By leveraging the [LLVM](http://llvm.org/)
bytecode engine you're able to reach the limits of portability.
So VSL aims to solve _all_ of these problems

Additionally due to careful design and implementation choices, VSL compiles to
very similar ASM to what a C-implementation would produce.
- **Portability**: By leveraging the [LLVM](http://llvm.org/)
bytecode engine VSL can compile to almost all targets and is designed for simple
compatibility with existing C projects.

By using syntax sugar, and powerful type-negotiation, VSL has one of the best
type deduction algorithms. Combined with low compilation overhead, VSL can
generate code with bare minimum boilerplate and guarunteed saftey at compile-time.
- **Fast**: Due to careful design and implementation choices, VSL compiles to
very similar ASM to what something written in a low-level language such as C
would produce.

VSL uses high-level syntax to be able to write code that works for all types of
programmers, whether you are functional, OO, scripting, or low-level engineer,
VSL works for embedded applications up to server apps.
- **Safe**: By using syntax sugar, and powerful type-negotiation, VSL has one
of the best type deduction algorithms. Combined with low compilation overhead,
VSL can generate code with bare minimum boilerplate and guarunteed saftey at
compile-time.

VSL is also reliable by using trusted libcurl, and glibc backends which are well
established and highly developed libraries for performing tasks at the low-level.
Due to this, VSL has powerful low-level pointer interopability and the power of
full OO-classes, but assembly-level bit alignment.
- **Powerful**: VSL uses high-level syntax to be able to write code that works
for all types of programmers, whether you are functional, OO, scripting, or
low-level engineer. Through both high-level interfaces for low-level functions,
you can use VSL for tasks low-level such as read/writing bits from a serial port
to running a server.

- **Reliability**: through bindings of reliable, trusted, and industry-standard
libraries such as libcurl, and glibc backends, VSL has powerful low-level
pointer interopability and the power of full OO-classes, but assembly-level bit
alignment.

## Examples
VSL functions both as a scripting and a full-blown language so two alterntaives
Expand Down Expand Up @@ -132,11 +143,3 @@ fizzbuzz(i where i % 3) -> "Fizz"
fizzbuzz(i where i % 5) -> "Buzz"
fizzbuzz(i) -> String(for: i)
```

```
func fizzbuzz(to i: Int) {
for i in 0..i {
print fizzbuzz(of: i)
}
}
```
16 changes: 8 additions & 8 deletions libraries/libc/libc.vsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// VSL is dynamically linked to libc (usually glibc) at runtime. However since
// the standard library for VSL is itself implemented in VSL. This adds a series
// of bindings, a "header" file of sorts for VSL, marking the names of which the
// functions are internally binded too.
// functions are externally binded too.
//
// Note: Not all functions are binded. Only ones used in the VSL standard
// library.
Expand Down Expand Up @@ -36,8 +36,8 @@ public typealias CString = Pointer<Char>
* @param {Double|Float} base - The base of the power
* @param {Double|Float} power - The number to raise the base by
*/
public func pow(base: Double, power: Double) -> Double internal(pow)
public func pow(base: Float, power: Float) -> Float internal(powf)
public func pow(base: Double, power: Double) -> Double external(pow)
public func pow(base: Float, power: Float) -> Float external(powf)

/**
* Given a pointer to a CString, returns the length as an `Int`. This calls the
Expand All @@ -48,7 +48,7 @@ public func pow(base: Float, power: Float) -> Float internal(powf)
*
* @param {CString} cstring - A `CString` object which to calculate length of
*/
public func strlen(cstring: CString) -> CSize internal(strlen)
public func strlen(cstring: CString) -> CSize external(strlen)

/**
* Given two CStrings, compares the two C-Strings and determines equality. This
Expand All @@ -59,7 +59,7 @@ public func strlen(cstring: CString) -> CSize internal(strlen)
*
* @return {Int} `== 0`: The two are equal. `< 0`: `s1` < `s2`. `> 0`: `s1` > `s2`
*/
public func strcmp(s1: CString, s2: CString) -> Int internal(strcmp)
public func strcmp(s1: CString, s2: CString) -> Int external(strcmp)

/**
* Given a CString, copies each byte of the string to the new pointer. This
Expand All @@ -68,7 +68,7 @@ public func strcmp(s1: CString, s2: CString) -> Int internal(strcmp)
* @param {CString} s1 - The source string
* @param {CString} s2 - The destination pointer which the string will be placed
*/
public func strcpy(s1: CString, s2: CString) -> Void internal(strcpy)
public func strcpy(s1: CString, s2: CString) -> Void external(strcpy)


// -----------------------------------------------------------------------------
Expand All @@ -95,7 +95,7 @@ typealias FILE = OpaquePointer
* null-pointer, check for errors. Using the other functions. If you don't
* know how to do this (because I don't), go read the C docs.
*/
public func fopen(filename: CString, opentype: CString) -> FILE internal(fopen)
public func fopen(filename: CString, opentype: CString) -> FILE external(fopen)

/**
* This function causes stream to be closed and the connection to the
Expand All @@ -115,4 +115,4 @@ public func fopen(filename: CString, opentype: CString) -> FILE internal(fopen)
* closed. Check this as the buffer may of not been fully written and that
* is usually not good.
*/
public func fclose(stream: FILE) -> Int internal(fclose)
public func fclose(stream: FILE) -> Int external(fclose)
69 changes: 69 additions & 0 deletions libraries/libcore/Array.vsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// omy y so long `enumeration` and not `enum` ;_;
///should this be inside Array
// imo we don't need `Enumeration<>` because always going to be enum
// yean but inheritance. i mean internally probably won't inherit because enum
// polymorphism shouldn't really be a thing because independent so would
// implicitly subclass Object but would implicitly conform to static polymorphic
// standards in VSL.
// imo this is better though because implies implicit cast
// v-- here

// Wait what is Iterator<Boolean> mean
// oh like Iterable object?
// uhh idk supposed to be like generator
// how about we have like Sequence type and `T[]` is actually sequence type.
// isn't T[] array
// but signature wrong it needs to be able to recieve state -> return next comparison?
// or recieve array but imo should be same for both in-place and not
enum SortingMethod<T> { // is this correct associated array syntax
// // ok wrong signature it needs to recieve state and decide on next
// Merge = MergeSort = (T, T) -> //do we capitalize s
// how about:

// imo look beter with `case`
case merge, quicksort

// ok idea but imo should be DRY so we can just use same code, only changing the assignment in the
// Array class method impl (sort vs sorted)
// but wouldn't they use different impl. because u can have major optimize
// if doing inplace or copy
// no, only default sort method would be different
// but slow ;_; shouldn't be slow we can make them inline or whatever but brb 3 minutes late already
public fn sort<T>(sequence: T[]) -> T[] {
switch self {
case .merge:
if array.length > 2 {
return self.merge(
self.sort(array.tail(#middle)),
self.sort(array.head(#middle))
)
} else {
return [array.min, array.max]
}
case .quicksort:
// ...
}
}
}

public class Array<T> {
// do we use hash for enum member?
// we use `EnumName.member`
// example:
// [1,2,3].sort()
// [1,2,3] sort using: .quicksort /// :D i use comand chain
public fn sort(using method: SortingMethod = .merge) -> Array<T> {
// Quetion: is `self` reserve word?
// self should be reserve so you don't do like `let self` and
// cause uber bork beacuse function would eb like:
// define i8* sort(i8* %self, i32 %method) {
// %2 = alloca i8*, i64 getelementptr inbounds (%0, i64 1)
// ret i8* %2
// }
// so because self is there imo make sense to make a parm
}

public var sorted: T[] {

}
}
8 changes: 8 additions & 0 deletions libraries/libnatural/Int.vsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// reopen class ruby style
public class Int {
// Ordinals
st => this
nd => this
rd => this
th => this
}
2 changes: 1 addition & 1 deletion libraries/libvsl/src/Int.vsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import libc

/**
* An integer. Defines as a 32-bit or 4-byte integer, use this for day-to-day
* An integer. Defined as a 32-bit or 4-byte integer, use this for day-to-day
* numerical operations
*/
public class Int: SignedNumber<Int> {
Expand Down
10 changes: 5 additions & 5 deletions libraries/libvsl/src/String.vsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import libc
* Strings are designed to offer a layer of abstraction over their C-counterpart
* to achieve this, most of the low-level C interfaces have been removed and are
* marked `@unsafe`, using these will break type-safety. Be advised that in 99%
* of senarios there is a better way to do something than use these. If you do
* of scenarios there is a better way to do something than use these. If you do
* need a C-String, use `.cString` to obtain a copy of the string (a `CString`).
*/
public class String<T: StringView = UTF8View>: Equatable {
Expand All @@ -33,8 +33,8 @@ public class String<T: StringView = UTF8View>: Equatable {
// size_t length;
// }

private let value: CString
private let length: CSize
private const value: CString
private const length: CSize

/**
* Given a C-String (optionally null-termianted) along with a defined
Expand Down Expand Up @@ -120,7 +120,7 @@ public class String<T: StringView = UTF8View>: Equatable {
@inline @unsafe
public func byte(at index: Int64) -> Char {
// Copy pointer, increment by `index`
let ptr: Pointer<Char> = self.value.getptr(at: index)
const ptr: Pointer<Char> = self.value.getptr(at: index)

// Return the value
return ptr.dereference()
Expand Down Expand Up @@ -150,7 +150,7 @@ public class String<T: StringView = UTF8View>: Equatable {


// Internally maintains a CharacterView of this string
private lazy let characterView: T = T(of: self)
private lazy const characterView: T = T(of: self)

/**
* Determine the UTF-8 length of this string. This means glyphs such as
Expand Down
3 changes: 1 addition & 2 deletions libraries/libvsl/src/UTF8View.vsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public class UTF8View: String {

// Internally holds the string
private let string: String
private const string: String

/**
* Constructs a UTF8View of a given string. This is the best way and fastest
Expand All @@ -25,5 +25,4 @@ public class UTF8View: String {
// }
// return counter
}

}
Loading