{"id":16248469,"url":"https://github.com/smashwilson/segment","last_synced_at":"2025-03-19T19:32:03.241Z","repository":{"id":15645223,"uuid":"18382361","full_name":"smashwilson/segment","owner":"smashwilson","description":"Most programmers, at some point, daydream about writing their own programming language. This one's mine.","archived":false,"fork":false,"pushed_at":"2022-03-13T07:18:42.000Z","size":232,"stargazers_count":6,"open_issues_count":6,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T20:40:16.059Z","etag":null,"topics":["c","language","programming-language","segment"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smashwilson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-02T21:36:56.000Z","updated_at":"2025-02-12T14:56:22.000Z","dependencies_parsed_at":"2022-09-13T00:32:14.286Z","dependency_job_id":null,"html_url":"https://github.com/smashwilson/segment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashwilson%2Fsegment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashwilson%2Fsegment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashwilson%2Fsegment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashwilson%2Fsegment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smashwilson","download_url":"https://codeload.github.com/smashwilson/segment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244014179,"owners_count":20383715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","language","programming-language","segment"],"created_at":"2024-10-10T14:41:55.825Z","updated_at":"2025-03-19T19:32:02.913Z","avatar_url":"https://github.com/smashwilson.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/smashwilson/segment.svg?branch=master)](https://travis-ci.org/smashwilson/segment)\n\nMost programmers, at some point, daydream about writing their own programming language. This one's mine.\n\n## What's all this then\n\n**Segment** is a dynamic, interpreted language in the spirit of Ruby and Python. It's a little closer to Smalltalk than Ruby: notably, general-purpose blocks are a first-class concept, and it has no built-in control structures or keywords.\n\nDependency management is a central concept, used to version the standard library. Method lookup is dependent on receiver class and lexical scope, both preventing \"dependency hell\" - two packages can depend on different versions of a common dependency without conflict - and offering a class extension facility similar to Ruby's refinements.\n\n## Features\n\nConsidering that the interpreter doesn't even have a `main` yet, this is all pure speculation.\n\n * Proper keyword arguments.\n * Inheritance by mixin, which, okay, I'm basically lifting wholesale from Ruby. Although I did have some thoughts about isolating instance variables within each mixin, and I'm going to try to keep conventional subclassing out of the language, if I can.\n * No `null`, `nil`, or `nothing`! There will be an `Optional` mixin in the core library, included in the `Some` and `None` classes, with handy methods for dealing with presence or absence, or iterating like a one-element collection.\n * Define your own operators and operator-like methods. Operator methods end with one of the standard `*`, `+`, `/` operator characters and have the precedence of their trailing character. This will let me write an `int/` method, for example.\n * More standard data structures than `Hash` and `Array`. I'll likely steal something like Scala's map construction syntax.\n * Unicode support from the get-go, because it's a giant pain to roll it in later.\n * Garbage collection with a proper generational garbage collector, because I've always wanted to write one. Statistics and functionality exposed through an in-language API.\n * Maybe JIT compilation with LLVM.\n\n## Great, But What Does It Look Like?\n\nDefine classes and methods with the `class` and `method` methods:\n\n```\nclass :Box {\n  constructor { |value|\n    @value = value\n  }\n\n  def :value { @value }\n\n  # Which is really just a method call:\n  # self.def(:value, { @value })\n}\n\n%box = Box.new(10)\nputs %box.value()  # =\u003e 10\n\n# The %-sigil is for temporary variables.\n# It closes that weird Ruby syntax hole where:\n#\n#   foo = 10\n#\n# ... could mean either \"assign 10 to foo\", or \"call self.foo=(10)\".\n\nif (%box.value() == 10) then: {\n  puts \"Hooray!\"\n} else: {\n  puts \"Oh no!\"\n}\n\n# Which is really the method call:\nself.if(%box.value().==(10), { puts(\"Hooray!\") }, { puts(\"Oh no!\") })\n```\n\nSee the [examples](examples/) directory for more samples of what it'll look like.\n\n## Getting Started\n\nIf you're on a Mac with Homebrew, or a Linux box with apt, you can clone it and run:\n\n```bash\nscript/bootstrap\n```\n\nIf you don't have those things, [`script/bootstrap`](script/bootstrap) is good documentation on what dependencies you'll need to install on your platform of choice. I'm using [lemon](http://www.hwaci.com/sw/lemon/) as a parser generator and [ragel](http://www.complang.org/ragel/) for the lexer.\n\nOnce you've got that, build it with:\n\n```bash\nmake\n```\n\n...and watch it break. :wink:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashwilson%2Fsegment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmashwilson%2Fsegment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashwilson%2Fsegment/lists"}