Skip to content

Commit

Permalink
fixed internal link bug; updated readme, license, style.css; added ne…
Browse files Browse the repository at this point in the history
…w article
  • Loading branch information
judahcaruso committed Aug 23, 2023
1 parent 1c9c62d commit 9f0353f
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 21 deletions.
30 changes: 13 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
MIT License

Copyright (c) 2023 Judah Caruso

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ go run . --server=true --port=8080 # start local server at port 8080

## Licensing

All source code within this repository (.go, .htm, .css) is licensed under [MIT](./LICENSE). Images, text, and audio files (.png, .riv, .ogg) are licensed under [CC-BY-SA-4.0](./LICENSE.CC-BY-SA-4.0).
All source code within this repository (.go, .htm, .css) is licensed under [zlib](./LICENSE). Images, text, and audio files (.png, .riv, .ogg) are licensed under [CC-BY-SA-4.0](./LICENSE.CC-BY-SA-4.0).

3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ func styledTextToHtml(index *Index, page *Page, text []StyledText) string {
display = p.DisplayName
}

fmt.Fprintf(&b, "<a class=%q href=%q>%s</a>", classIntLink, page.OutName, display)
p.Refs += 1
fmt.Fprintf(&b, "<a class=%q href=%q>%s</a>", classIntLink, p.OutName, display)
} else {
log.Printf(".. '%s' has a broken internal link '%s'\n", page.LocalName, t.Link)

Expand Down
2 changes: 1 addition & 1 deletion res/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ main pre {
font-size: 90%;
font-family: monospace;
line-height: 1.4;
margin-bottom: 30px;
margin-bottom: 20px;
overflow-y: hidden;
}

Expand Down
276 changes: 276 additions & 0 deletions riv/language-for-productivity.riv
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
A LANGUAGE FOR PRODUCTIVITY

This file is a "living" document of notes and ideas for a productivity-focused programming language. I do not mean to imply languages of the modern age are designed with productivity as an afterthought. In fact, it's quite the opposite. Languages like Python, JavaScript, C++, and Rust were all designed to be more "expressive" and claim to improve productivity.

However, these languages have a common pitfall: productivity is relative to the amount of philosophical buy-in.

A programmer only becomes more productive in these languages as they do things the "right way" (as defined by the language or expected domain). The moment they do things outside of the philosophy they have to fight the language or change their solution to fit back in the box. If they're lucky, the language designers will evolve the language to fit the domain at the cost of complexity.

See:
. TypeScript's type system
. Python type hints
. Any C++ specification after C++98
. Rust's async traits

\. . .

THE COMPILER SHOULD BE EASY TO IMPLEMENT

. Compilers should evolve, but should **not** take decades to reach 1.0
.. Core expectations need to be defined from the start
.. The language should **not** cater to a specific domain until these expectations are fully defined
.. "Will Not Implement" needs to be a frequently used phrase
. A baseline compiler for a specific target should take a **week** at most, ideally a **weekend**
.. Baseline as-in: declarations, control flow, base type system (**no** pointer mutability, polymorphism, or methods), and code generation
. A spec should **not** be created until 1.0, instead a large test suite to ensure stability should be used
. Alternate implementations should not be encouraged until 1.0
. The spec should avoid "implementation defined" details


THE LANGUAGE SHOULD STAY SIMPLE

. 1.0 should mark a stopping point for large language changes
. Source code five years after a major version should compile on the same architecture
. Major versions (2.0, 3.0, etc.) should be the removal point of deprecated standard library features
. Major versions should be a reflection point for how the language is used in its most popular domains
.. This reflection point should allow smaller quality-of-life changes to be added to the language


CUSTOM MEMORY MANAGEMENT

Most designers pick a memory model and throw away the others, limiting the number of applicable domains.

. The memory model should start out as manual and the language should provide features to manage the memory in a simple way
. Allocators should be first class citizens
.. Features to manage allocated memory and share it between allocators is required
. Allocators should always be in userland, memory allocation should not be an implementation detail of the compiler
.. In this world, garbage collection is an allocator you opt into
.. In this world, reference counting is an allocator you opt into
.. In this world, memory is controlled, not feared


KEYWORDS OVER DIRECTIVES

. Directives are bespoke, usually implementation specific, and are different from the language; they should be avoided
. Keywords limit user naming but that doesn't matter
. Keywords should be reused in different contexts, rather than adding more:
.. for, while -> for
.. if, switch, ? -> if
.. else, : -> else
.. case, default -> case
.. continue, fallthrough -> continue


USER-LEVEL CODE OVER INTRINSICS

. Intrinsics, like directives, are magic procedure-like entities that are internal to the compiler and can't be inspected in userland
. Intrinsics, should be relegated to an importable package; their usage should be explicit


RESTRICTIVE SYNTAX

. Syntax won't make a bad language usable but, will make a good one better
. Standard formatting should be enforced by the compiler, remove code style from the programmer's brain
. The syntax should look the same everywhere, spaces over tabs
. K&R bracing style: foo() {
. Spacing should be placed between around operators: x==y -> x == y
. Parentheses should not be required for conditionals or loops: if (x) { -> if x {
. Inline statements should not be allowed: if x return 10 -> if x {


FOLDER-BASED PACKAGES & EXPLICIT DEPENDENCIES

. Folder-based packages are annoying but clearly describe the structure of code
. Prelude packages are annoying and shouldn't exist
. A namespace defaults to the enclosing folder's name
. Dependencies should default to local vendoring over external fetching
. Dependencies, their source (not source code), version, and a checksum should be declared explicitly within a package - this can be an separate file, but it must be done


NO MORE VOID POINTERS

. void* is a great tool within a poor type system
. A dereference of void* becomes a unit type who's semantics don't align with the rest of the language (what's the zero-value of void?)
. A specific type (rawptr) should be created that allows T* -> rawptr conversions
. rawptr should not cast to other pointer types automatically, however, it should be allowed to do so if done explicitly
. rawptr must be cast before dereferencing is allowed (no zero-value is needed)
. Pointer arithmetic is not allowed. Pointers must be cast to rawptr then to a pointer sized integer and back: T* <-> rawptr <-> intptr (rawptr is the bridge to type unsafe code)


NO MORE IMPLICIT CONVERSION

. Implicit conversion is nice from a writing perspective, but terrible from a grokking one
. All conversions are explicit
. Untyped constants (integers, floats, bools, etc.) are range-checked at compile time to ensure their conversion is safe, otherwise they follow the rules of everything else
. The language should feature an auto cast keyword/operator to make explicit conversion less annoying to work with


TYPES SHOULD DESCRIBE THE DATA

. Types and data should not exist in separate worlds and rely on deserialization to communicate
. Types should not rely on workarounds or directives to accurately model their data
. Integers and booleans should not be fixed size (ie. uint1, sint7, bool3)
. Alignment and padding of struct fields should be configurable in their declaration


DATA SHOULD BE MUTATED

. Everything is mutable by default (only const declarations and const pointers cannot be mutated)
. Everything is public by default (only local declarations are kept to the current module)


ERRORS SHOULD JUST BE VALUES

. Errors should be simple values that the language allows special handling of (see: Zig)
. Data can be attached to errors so the world can stop relying on error code and GetErrorMessage(code) styles of handling


THE BUILD SYSTEM SHOULD BE THE LANGUAGE

. Shell scripts, makefiles, etc. should **not** be required to build complex projects in this language
. The build system should **not** use a subset of the core language
.. This leads to a scripting language with the flavor of the main one


COMPILER TOOLING SHOULD NOT BE FIRST CLASS

. The compiler must remain small and easy to grok; adding tools to the core makes reimplementing more difficult than it needs to be
. The standard library should provide helpful packages to make writing external tools easier


\. . .


SYNTAX IDEAS

Some syntactic ideas to outline how certain features would work:

*Structs and methods:*

// struct declaration
User :: struct {
Name string // string type (pointer + length)
Age sint // signed integer
Friends [..]*User // dynamic array type
}

// "constructor"
MakeUser :: fn(name string, age sint) User {
// type-inferred struct literal
return .{
Name: strings.Clone(name),
Age: age,
Friends: .[], // type-inferred array literal
}
}

// Method (first argument is User)
AddFriend :: fn(u *User, f *const User) void {
if u.Friends == nil {
u.Friends = mem.Make([]*User, 1)
}

// error handling
mem.Append(*u.Friends, f) catch e {
log.Fatal(e)
}
}

RemoveFriend :: fn(u *User, f *const User) void {
if u.Friends == nil {
return
}

// for-each loop (i is optional)
for fp, i in u.Friends {
if fp != f {
continue
}

// ...
}
}

RemoveFriendById :: fn(u *User, id usize) void {
if u.Friends == nil || id >= len(u.Friends) {
return
}

// ...
}

// Return type is always required
Release :: fn(u *User) void {
if u.Name != nil {
mem.Release(u.Name)
}

if u.Friends != nil {
mem.Release(u.Friends)
}
}

main :: fn() void {
// variable declarations
bob := MakeUser("Bob", 88)
jon := MakeUser("Jon", 94)

// scoped defer
defer {
bob.Release()
jon.Release()
}

// method calls
bob.AddFriend(jon)
jon.AddFriend(bob)

bob.RemoveFriend(jon)
}


*Build system:*

A small example of building the language **in** the language.

// within a build.lang file
build :: fn(package *build.Package, options *build.Options) !void {
package.* = .{
Type: .Binary,
Name: "my package",
Version: "0.0.1",
Authors: .[ "my name <[email protected]>" ],
Link: "https://github.com/my-name/my-package",
}

// change build based on command-line arguments passed to the build command
args := options.Args
for arg in args {
// switch statement (each branch breaks unless continue is used)
if arg in {
case "-d", "debug", "--debug":
options.DebugInfo = true
options.Optimization = .None // anonymous enums

case "-r", "release", "--release":
options.Optimization = .ReleaseSmall

case:
options.DebugInfo = true
options.Optimization = .None
}
}

// anonymous switch statement (breaks on the first true branch unless continue is used)
if {
case options.Optimization == .None:
fmt.Println("Compiling with no optimizations...")
continue

case options.DebugInfo:
fmt.Println("Compiling with debug info...")
continue

// a default case here would always be executed
}
}
2 changes: 1 addition & 1 deletion riv/whoami.riv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ me-and-mika.png Me (288+ months old) and Mika (11 months old)

Hi, my name is Judah Caruso and I like to make things. Below is a small set of questions you may or may not care about:
Hi, my name is Judah Caruso and I like to make things, especially {language-for-productivity programming languages}. Below is a small set of questions you may or may not care about:


DO YOU HAVE SOCIAL MEDIA?
Expand Down

0 comments on commit 9f0353f

Please sign in to comment.