TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Whack – A simply-designed compiled programming language

57 pointsby wycliffbover 6 years ago

13 comments

SamReidHughesover 6 years ago
I only looked for a few minutes, so first impressions:<p>1. Try the declaration syntax<p><pre><code> x Foo; </code></pre> instead of<p><pre><code> Foo x; </code></pre> I tried it before, you might like it.<p>2. I think the way you&#x27;re defining the AST types is a crapload of work. You should have had a bunch of dumb structs, all in one file.<p>Then you can see everything at once, and you aren&#x27;t mixing AST representation with codegen logic. Sometimes that&#x27;s a better way to do algebraic types in C or C++.<p>3. I don&#x27;t know what &quot;type Foo struct {...}&quot; does but you&#x27;ll save a lot of work if the type system only has names as types, nominative typing, without losing usability.<p>4. Personally I&#x27;d parse straight to the AST type you define and not use the mpc lib with its own AST implementation. I don&#x27;t believe in parser combinator libraries, especially not in C. It&#x27;s better to copy&#x2F;paste those loops. Better than using a parser generator too. But since you have a parser already... not right now.<p>Edit: 5. Avoid looking at Zig, Myrddin, etcetera, if you can. There are obviously paths that any C-like language tends to go down in the 21st century, and the world would probably be better if you rethought the problems from a blanket slate.
评论 #18320114 未加载
评论 #18354684 未加载
fuddleover 6 years ago
It would be a good idea to add some examples to the readme.
评论 #18326078 未加载
wycliffbover 6 years ago
Will appreciate comments on the implementation&#x2F;design choices.
评论 #18319502 未加载
joshumaxover 6 years ago
Interesting project! I&#x27;ve written compiler frontends for both GCC and LLVM, and surprisingly found it easier to write one for GCC, despite LLVMs reputation on modularity. I&#x27;d love to hear the reasons why you chose LLVM for code generation over something else!
评论 #18322152 未加载
otabdeveloper2over 6 years ago
&gt; Whack currently lacks a comprehensively designed type system.<p>The type system is 90% of programming language design effort.<p>This is like releasing a car without a &#x27;comprehensively designed engine&#x27;.
评论 #18319876 未加载
pppaulover 6 years ago
would recommend looking into writing a grammar, have that generate your AST, then do some transformations on the AST to generate code. you will save a lot of time.<p>I recently did that for a language that i made, via instaparse. the flexibility and speed i gained was very big. my language isn&#x27;t Turing complete, but it has functions, lookup tables, and some pattern matching.
评论 #18323355 未加载
Myrthover 6 years ago
Amazing job, thank you for sharing!
devoplyover 6 years ago
I wanna see a language that is both dynamic and can be compiled. Runs on a VM and on bare metal. Something like C++, Java, and Python combined. It can definitely be done and would be an interesting exercise.
评论 #18323460 未加载
nsstring96over 6 years ago
This is super cool, thanks for sharing! Are there any books or other resources that you found helpful in learning and implementing Whack? I’m dabbling a little bit with PLs and would love to hear your opinion.
评论 #18322621 未加载
评论 #18353812 未加载
wycliffbover 6 years ago
Just pushed LLVM.dll to snapshot folder.
webkikeover 6 years ago
&gt; Whack currently lacks a comprehensively designed type system.<p>To me, this statement means: currently whack is not a properly designed programming language.<p>Proofs are an important part of programming! This is the most important part.
评论 #18319789 未加载
评论 #18320792 未加载
lewisj489over 6 years ago
Shwacked
xixixaoover 6 years ago
I know that mentioning other language on a thread about A language is contentious, but if you haven’t played with Nim, I seriously recommend you check it out.