TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Pretty.c

370 点作者 synergy207 个月前

49 条评论

sneed_chucker7 个月前
Creating DSLs within C has a long tradition.<p>Stephen Bourne wanted to write his shell in ALGOL so badly that he relentlessly beat C with its own preprocessor until it began to resemble his preferred language.<p><a href="https:&#x2F;&#x2F;www.tuhs.org&#x2F;cgi-bin&#x2F;utree.pl?file=V7&#x2F;usr&#x2F;src&#x2F;cmd&#x2F;sh&#x2F;mac.h" rel="nofollow">https:&#x2F;&#x2F;www.tuhs.org&#x2F;cgi-bin&#x2F;utree.pl?file=V7&#x2F;usr&#x2F;src&#x2F;cmd&#x2F;sh...</a>
评论 #41936014 未加载
评论 #41936403 未加载
评论 #41942323 未加载
codeflo7 个月前
Can someone clarify whether this is intended as a joke or whether the author is actually confused? I mean, nothing about this makes sense: it&#x27;s not &quot;scripting&quot;; it claims to introduce &quot;strong typing&quot; while it does nothing about typing; it introduces all kinds of operator aliases &quot;modeled after Lua and Lisp&quot; that are present in neither of these languages. But it&#x27;s not an obvious parody either, so I&#x27;m genuinely not sure.
评论 #41934082 未加载
评论 #41933758 未加载
nneonneo7 个月前
It claims to be a scripting language but you still have to compile the programs. Boo! Add CINT (<a href="https:&#x2F;&#x2F;root.cern.ch&#x2F;root&#x2F;html534&#x2F;guides&#x2F;users-guide&#x2F;CINT.html" rel="nofollow">https:&#x2F;&#x2F;root.cern.ch&#x2F;root&#x2F;html534&#x2F;guides&#x2F;users-guide&#x2F;CINT.ht...</a>) and you can have instantaneous execution and even a REPL!
评论 #41933972 未加载
评论 #41933769 未加载
评论 #41934998 未加载
评论 #41934238 未加载
kvirani7 个月前
&gt; Provide so much syntactic sugar as to cause any C developer a diabetes-induced heart attack.<p>Haha love this!
shakna7 个月前
Well, there&#x27;s a few things I should probably get around to adding to CNoEvil[0] and ogw[1]... There always seem to be more every few months when this project reappears.<p>[0] <a href="https:&#x2F;&#x2F;git.sr.ht&#x2F;~shakna&#x2F;cnoevil3&#x2F;" rel="nofollow">https:&#x2F;&#x2F;git.sr.ht&#x2F;~shakna&#x2F;cnoevil3&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;git.sr.ht&#x2F;~shakna&#x2F;ogw" rel="nofollow">https:&#x2F;&#x2F;git.sr.ht&#x2F;~shakna&#x2F;ogw</a>
评论 #41941359 未加载
IgorPartola7 个月前
For what it’s worth this makes the same mistake that Python 2 did: string and bytes are not the same type and shouldn’t be treated as such.
评论 #41935981 未加载
评论 #41935358 未加载
评论 #41936720 未加载
评论 #41935348 未加载
gpuhacker7 个月前
Reminds me of a C++ codebase I once had to inspect that was entirely written as if it were written in Java. With camelcase naming for everything, getters and setters for every class variable, interfaces everywhere.
评论 #41932918 未加载
评论 #41933012 未加载
评论 #41933995 未加载
评论 #41932795 未加载
评论 #41933044 未加载
评论 #41934954 未加载
Alifatisk7 个月前
If you find this interesting, you might like libcello.h aswell! <a href="https:&#x2F;&#x2F;www.libcello.org" rel="nofollow">https:&#x2F;&#x2F;www.libcello.org</a>
评论 #41935104 未加载
Uptrenda7 个月前
Type names are nice; Perfect choice for the in-built func macros (like min); Len -- love it. Named boolean operators -- might be a bit much but go for it; Ternaries are illegible so you can only improve them; Not completely sold on all your loop definitions but some make sense to me; Resource tracking is impressive; The for... look a bit ugly -- could probably call it something else.<p>All in all: quite a solid attempt. I&#x27;ll give you 8&#x2F;10 for the design of this. The way you sketched this out in C using macros is really elegant. This actually looks like good code. Would I use it? It&#x27;s a new language and I like C already. It could help people learn C and think about language design. Since the way you&#x27;ve done this is very clear.
评论 #41934372 未加载
tromp7 个月前
&gt; ifnt for if(!...).<p>&quot;unless&quot; seems more readable than &quot;ifnt&quot;.
评论 #41932896 未加载
评论 #41938786 未加载
评论 #41934255 未加载
textread7 个月前
Is it possible to tangle the Readme into pretty.h? In other words, are the codeblocks in the orgfile exhaustive.<p>I love the literate way you have explained your thought process in the readme.
评论 #41934305 未加载
yjftsjthsd-h7 个月前
I have not decided how I feel in general, but:<p>&gt; Everyone defines these, so why not provide them?<p>Honestly, that&#x27;s fair.
dymk7 个月前
&gt; turn any codebase into a beginner friendly one<p>Okay then.<p>I was hoping to see a “this is just for fun” disclaimer but didn’t see one. Please never actually use this in a project that other people will have to read or contribute to.
评论 #41932264 未加载
评论 #41934490 未加载
评论 #41936592 未加载
mydriasis7 个月前
Wow, neat! The wildest part to me is<p>&gt; And it’s backwards-compatible with C and all of its libraries!<p>I can&#x27;t wait to give it a shot! This looks like a riot.
评论 #41932625 未加载
jay-barronville7 个月前
This project looks really cool! Unfortunately, there’s just way too much magic involved. In my humble opinion, C is simply not the language for this level of magic—extreme use of macros (and hidden behavior in general) is how you end up with hard-to-detect (and hard-to-debug) bugs and security vulnerabilities. As cool as this project looks, I’d never feel comfortable using it in anything serious. A+ for the effort though!
lpapez7 个月前
All that is missing is a garbage collector. Should be possible to implement one by overriding malloc &amp; friends?
评论 #41933235 未加载
drbaggy7 个月前
Being able to control indents for a particular case { right-aligning variable names - while keeping &quot;=&quot; in line can be useful for instance }... Is the perfect example of why indenting should be left for the eye of the reader not the computer.<p>It&#x27;s exactly why I find python code difficult - nay impossible - to read at times.<p>So you are really doing absolutely the opposite of what you are claiming...<p>Obviously beauty is in the eye of the beholder - but the one thing that C got right was using &quot;{&quot; &amp; &quot;}&quot; to specify code flow.
nanis7 个月前
&gt; if (argc above 1)<p>I give up.
评论 #41934400 未加载
OsrsNeedsf2P7 个月前
This is terrifying
评论 #41934352 未加载
DeathArrow7 个月前
This should have been invented 50 years ago!
评论 #41934331 未加载
pineaux7 个月前
I feel compelled to try it out in a serious way and contribute to it. I have strong knowledge of python and am learning C. Are there good reasons -apart from attracting the ire of c-programmers- to not use it?
评论 #41934381 未加载
bitwize7 个月前
I&#x27;m reminded of the guy who did<p><pre><code> #define BEGIN { #define END } </code></pre> and a whole bunch of other macro-larkey just to make C look more like Pascal. Only then would he deign to code in it.
评论 #41932433 未加载
Validark7 个月前
Evil, yet beautiful. Hats off to you.
评论 #41934354 未加载
throwaway199727 个月前
Does &quot;strong typing&quot; now just mean &quot;static typing&quot;? Afaik both lua and python are already strongly typed. Javascript is not and I have no clue about ruby.
评论 #41934213 未加载
ipsum27 个月前
`equal(0.3, 0.2 + 0.1); &#x2F;&#x2F; true`<p>how is this wizardry possible?
评论 #41932442 未加载
评论 #41932353 未加载
评论 #41932438 未加载
评论 #41932439 未加载
varjag7 个月前
This made me immediately think whether MIT Loop of Common Lisp was an inspiration here. Checked the user&#x27;s profile and sure enough, a lisper!
评论 #41934356 未加载
dfox7 个月前
The code asumes that C17 has C++-style auto (<a href="https:&#x2F;&#x2F;github.com&#x2F;aartaka&#x2F;pretty.c&#x2F;blob&#x2F;master&#x2F;pretty.h#L118">https:&#x2F;&#x2F;github.com&#x2F;aartaka&#x2F;pretty.c&#x2F;blob&#x2F;master&#x2F;pretty.h#L11...</a>), it does not (in C auto is storage specifier that is equivalent to no storage specifier).
评论 #41934399 未加载
pipeline_peak7 个月前
For each looks convoluted, you shouldn’t have to list the type.<p>It should be no harder than C#’s foreach(var i in list)
评论 #41935212 未加载
taylorius7 个月前
Sorry for what is probably a stupid question. Does pretty.c act as a preprocessor or sorts, converting your pretty.c script into actual c, that is then compiled? Or is it a virtual machine that interprets your pretty.c script?
评论 #41935572 未加载
评论 #41935598 未加载
评论 #41935689 未加载
w4rh4wk57 个月前
I&#x27;ve seen this implementation of defer a few times now. I really dislike calling this defer (like the keyword in Go) as the given code won&#x27;t be executed on return.
评论 #41934328 未加载
stankot7 个月前
This reminded me of ArnoldC<p><a href="https:&#x2F;&#x2F;lhartikk.github.io&#x2F;ArnoldC&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lhartikk.github.io&#x2F;ArnoldC&#x2F;</a>
chris_wot7 个月前
I’m waiting for someone to write a lambda calculus based C++ library that allows everything to be defined in terms of function. Peano axioms and all.
leetsbehonest7 个月前
That is pretty cool
fnord777 个月前
I feel like this would have been cool 25 years ago
layer87 个月前
Given the title, shouldn’t that be #include &quot;pretty.c&quot; instead of #include &quot;pretty.h&quot;?
_benj7 个月前
&gt; The goals for Pretty C are:<p>&gt; Provide so much syntactic sugar as to cause any C developer a diabetes-induced heart attack.<p>:-D
评论 #41935367 未加载
azinman27 个月前
&gt; Deprecate Lua, Python, JavaScript, Ruby and a dozen other languages, because Pretty C is the ultimate scripting language, but lightning-fast and strongly typed!<p>Umm… that’s quite the goal.<p>I’ll stick with deprecated Python.
评论 #41933796 未加载
looopTools7 个月前
I cannot wait to show this to a colleague of mine. He will kill me XD
评论 #41934379 未加载
shiomiru7 个月前
&gt; max and min of two numbers.<p>Influenced by windows.h I see :)
nicman237 个月前
as someone that just started C, it looks pretty :)
评论 #41934411 未加载
swiftcoder7 个月前
This is as horrific as it is wonderful.
评论 #41934359 未加载
mjan226407 个月前
Are variadic macros turning complete?
评论 #41935466 未加载
MrLeap7 个月前
love. It.
评论 #41934383 未加载
jcmontx7 个月前
does this transpile to C or how does it actually work?
评论 #41938707 未加载
revskill7 个月前
Or just use Ruby.
cmcconomy7 个月前
someone&#x27;s salty about tiobe!
SuperHeavy2567 个月前
So sweet :))
评论 #41934384 未加载
ngcc_hk7 个月前
Can we just pascal?
评论 #41934389 未加载
unwind7 个月前
Meta: the naming is ... strange.<p>The actual name of the repo is &quot;pretty.c&quot;, but the name used for the language&#x2F;dialect&#x2F;result&#x2F;horrorshow[*] is &quot;Pretty C&quot;.<p>The actual code file you include is called &quot;pretty.h&quot;, which makes sense since it&#x27;s a header, of course. Confusing!<p>Edit: escapes.<p>[*] Yes, I&#x27;m a C programmer, currently hunting for black-marked insulin to combat the rapid-onset diabetic attack from all that sugar. Sorta.
评论 #41933008 未加载
评论 #41934715 未加载