diff --git a/.github/README.md b/.github/README.md index 3c2edfa..4a092c4 100644 --- a/.github/README.md +++ b/.github/README.md @@ -29,6 +29,38 @@ Helix is an experimental language designed for seamless interoperability with Py - **Rich Standard Library**: Extensive libraries to handle various programming tasks out of the box. - **Object-Oriented Programming**: Support for classes and objects, enabling encapsulation, inheritance, and polymorphism for modular and reusable code. +## Why Not Use Rust or Zig? + +At Helix, we believe there's a gap in the programming language space that neither Rust nor Zig fully addresses. While both languages have their strengths, they also have limitations that we aim to overcome with Helix. + +### Limitations of Both Rust and Zig + +- **Lack of OOP Support**: Both Rust and Zig lack comprehensive object-oriented programming (OOP) support. This can make certain types of applications, like AI development and game development, more cumbersome to implement. +- **Complex Syntax**: Both languages have syntaxes that can be verbose and complex, increasing the learning curve and potentially slowing down development. + +### Specific Limitations of Rust + +- **Strict Safety Mechanisms**: Rust’s borrow checker is often too strict, making it difficult for developers to write complex programs without extensive refactoring. +- **Verbosity**: The syntax of Rust can be cumbersome and verbose, which can slow down development and increase the learning curve. + +### Specific Limitations of Zig + +- **Limited Features**: While Zig is simple and performant, it lacks features like a preprocessor, which can limit its flexibility and control over the code compilation process. +- **Less Focus on Safety**: Zig does not emphasize safety to the same extent as Rust, which can lead to potential issues in memory management and concurrency. + +### Advantages of Helix + +Helix draws inspiration from the best parts of Rust, Python, Zig, and other modern languages, combining their strengths while addressing their weaknesses. + +- **Balanced Safety**: Helix includes a borrow checker for pointers and references, but it's less strict. Code that fails the borrow checker emits a severe warning instead of an error, allowing developers to proceed while being aware of potential issues. +- **Simpler Syntax**: Helix offers a syntax that is both modern and easy to use, inspired by Python’s simplicity. Variable/Paramater types are strict but flexiable, resembling Python’s syntax, making it more accessible to a broader range of developers. +- **OOP Support**: Unlike Rust, Zig, and Mojo, Helix supports OOP, which is crucial for certain domains like AI development and game development. This allows for more intuitive code organization and reuse through classes and inheritance. +- **Preprocessor**: Helix includes a preprocessor, providing additional flexibility and control over code compilation. + +Helix aims to offer the right balance between safety, simplicity, and flexibility, while also trying to be a better cross paltfrom C++, unlike Zig and Rust which both try to be a better C. + +Helix aims to extract the cleanest and best parts of C++ without the bloat and unreadablity of it, as said by Bjarne Stroustrup, "Within C++, there is a much smaller and cleaner language struggling to get out". Helix aims to be the smaller and cleaner langauge thats getting out. + ## Helix Syntax Examples ### Unique Type System diff --git a/libs/llvm-18.1.9-src b/libs/llvm-18.1.9-src new file mode 160000 index 0000000..0edafc4 --- /dev/null +++ b/libs/llvm-18.1.9-src @@ -0,0 +1 @@ +Subproject commit 0edafc461f5f98b2ed5d2d621e1d9de70ccbd4e5 diff --git a/xmake.lua b/xmake.lua index 8af63fe..eb3204b 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,60 +1,102 @@ +-- FIXME: rename main.cc to helix.cc set_project("helix-lang") +set_version("0.0.1", {soname = true}) add_rules("mode.debug", "mode.release") add_rules("plugin.vsxmake.autoupdate") -target("helix") - set_kind("binary") - set_warnings("all") - - add_files("source/**.cc") -- add all files in the source directory - - add_headerfiles("source/**.hh") -- add all headers in the source directory - add_includedirs("source") - set_languages("c++23") -- set the standard C++ version to C++23 +-- set up config + local function configure_runtime() + if is_kind("binary") then + if is_tool("cc", "cl") or is_tool("cxx", "cl") then + return "MT" + elseif is_tool("cc", "clang") or is_tool("cxx", "clang") then + return "c++_static" + elseif is_tool("cc", "gcc") or is_tool("cxx", "g++") then + return "stdc++_static" + end + end + return "" + end + local use_runtime = configure_runtime() + if is_mode("debug") then + if is_plat("windows") then + set_runtimes("$(use_runtime)d") + end set_symbols("debug") -- Generate debug symbols set_optimize("none") -- Disable optimization add_defines("DEBUG") -- Define DEBUG macro - set_runtimes("MDd") -- Use the debug version of the runtime library else + set_runtimes("$(use_runtime)") set_symbols("hidden") -- Hide symbols set_optimize("fastest") -- Enable maximum optimization add_defines("NDEBUG") -- Define NDEBUG macro - set_runtimes("MD") -- Use the release version of the runtime library end - if is_plat("macosx") then - add_syslinks("z", "c++", "System") + add_files("source/**.cc") -- add all files in the source directory + add_headerfiles("source/**.hh") -- add all headers in the source directory + add_includedirs("source") + set_languages("c++23") -- set the standard C++ version to C++23 + set_warnings("all") + set_kind("binary") + set_targetdir("$(buildir)/$(mode)/$(arch)-unknown-$(plat)/bin") + set_objectdir("$(buildir)/.resolver") + set_dependir("$(buildir)/.shared") + set_policy("build.across_targets_in_parallel", true) -- optimization + - add_cxxflags("-stdlib=libc++", "-static-libgcc", "-static", {tools = "clang"}) - - add_linkdirs("/usr/lib/") - add_links("z", "c++", "System") - end +-- end config target("tests") - set_kind("binary") - set_warnings("all") - add_files("tests/**.cc") -- add all files in the tests directory - add_files("source/**.cc") -- add all .cc files in the source directory and its subdirectories remove_files("source/main.cc") -- exclude main.cc from the source directory - - add_headerfiles("source/**.hh") -- add all headers in the source directory + add_headerfiles("tests/**.hh") -- add all headers in the tests directory - - add_includedirs("source") add_includedirs("tests/lib") - set_languages("c++23") -- set the standard C++ version to C++23 set_symbols("debug") -- Generate debug symbols set_optimize("none") -- Disable optimization add_defines("DEBUG") -- Define DEBUG macro - set_runtimes("MDd") -- Use the debug version of the runtime library +target_end() + +target("helix") +target_end() + +target("helix-api") + set_kind("static") + set_targetdir("$(buildir)/$(mode)/$(arch)-unknown-$(plat)") + + after_build(function (target) -- make the helix library with all the appropriate header files + import("core.project.task") + + -- Determine the target output directory + local target_dir = path.directory(target:targetfile()) + + -- Create directories for library and headers + os.mkdir(path.join(target_dir, "api/lib")) + os.mkdir(path.join(target_dir, "api/include")) + + -- Move the compiled library to the 'lib' folder + os.cp(target:targetfile(), path.join(target_dir, "api/lib/")) + os.rm(target:targetfile()) + + -- Copy header files to the 'include' folder + local headers = os.files("source/**.hh") + for _, header in ipairs(headers) do + local rel_path = path.relative(header, "source") + os.mkdir(path.join(target_dir, "api/include", path.directory(rel_path))) + os.cp(header, path.join(target_dir, "api/include", rel_path)) + end -if is_mode("debug") then - set_runtimes("MDd") -else - set_runtimes("MD") -end + local file = io.open(path.join(target_dir, "api", "xmake.lua"), "w") + file:write([[ +target("helix-api") + set_kind("static") + add_files("lib/*.a") + add_includedirs("include") + add_headerfiles("include/**.hh") +]]) + file:close() + end) +target_end()