
Show HN: Nymph – A slightly different version of C - nymph019283
https://github.com/roecrew/nymph/blob/master/README.md
======
FascinatedBox
This seems all over the place. You're marketing this to, what, people who have
experience in C and want a better experience?

Why is there a readme link to download a .zip of the repo? I know how to
clone.

Why is there a link to wikipedia's section on object orientation? I know that.

I don't understand the updates section. v3 parser implemented...okay? How is
that better? What?

Then this big example which looks a lot like vanilla C. Is this the sum of
what Nymph offers?

What I really want to know, and what is absent is:

* What does this give me that ordinary C doesn't?

* What are the longer-term goals of this project?

* Who is this intended for?

* How compatible will this be with ordinary C? Is there an interest in, say, gradual migration if this is to take off? What's the C <=> Nymph interop to look like?

~~~
nymph019283
"Why is there a readme link to download a .zip of the repo? I know how to
clone."

\- New users don't...

"Why is there a link to wikipedia's section on object orientation? I know
that."

\- Some people don't...

"What does this give me that ordinary C doesn't?"

\- Simple Objects and function Overloading (it says this on the readme)

"What are the longer-term goals of this project?"

\- Not entirely sure yet.

"Who is this intended for?"

\- People who have interests in preprocessors and the C Language.

"How compatible will this be with ordinary C?"

\- Very

~~~
Sammi
Your target audience is c programmers right? Which c programmer knows Object
Oriented Programming so poorly that you have to link to the Wikipedia article
about it?

~~~
nymph019283
It's for reference...

------
HaoZeke
I guess this could do with more details on the Readme... An api documentation
perhaps?

~~~
benbenolson
Yeah, the readme is definitely lacking... what are the design goals, and how
does it improve on C?

------
jstimpfle
This is of no use for me unfortunately. I don't miss OO syntax from C at all.
OO by default leads to badly architected software, as learned emprically from
many projects. I'm perfectly happy with the minimal OO support that C brings -
Just pass an explicit "vtable" (struct of function pointers) in the few cases
where it makes sense.

Instead of OO I would like to know if we can do something about the (mostly
compile performance) problem that importing external interfaces is done by
including text files, and that compilation means writing intermediate results
to disk.

Also there might or might not be a nice solution for better compile time code
generation (just for the rare things where it's really useful, like support
for type-generic value printing when debugging).

Jonathan Blow has made some really impressive advancements with his Jai
language (his own language) compiler
[https://www.youtube.com/watch?v=gWv_vUgbmug](https://www.youtube.com/watch?v=gWv_vUgbmug).
Compiling a game engine and a little game (50K lines of code I think) in less
than a second. Whether his ideas work out well in the end or just work for
himself remains to be shown, but it's very interesting to watch the video in
any case.

~~~
spease
Has there been any external verification of Jai?

~~~
jstimpfle
How do you mean? The compiler is not released yet, but he has done many
streams working on the compiler and on the game engine (both written in that
language) and answering questions. You can find them all on youtube.

------
dang
Making bogus accounts to upvote stuff will get your account banned on HN, as
well as the bogus accounts, as well as related accounts.

------
jitl
I think some comments in the example nymph code explaining what each line does
and the differences from C could go a really long way here.

Does malloc do something different? Explain in a comment.

What are the two different calls to `print()` supposed to demonstrate? How
does nymph know which one to call?

In the `obj` block, there are initializers/default values, it seems. When are
those set? How do they work?

------
tjalfi
previously discussed at [0].

Suggestions for the author:

Define the grammar in BNF and the semantics in prose.

Consider using a lexical scanner generator, a parser generator, and a string
library.

Don't call strlen in a loop[1], many of your for loops are O(n^2) instead of
O(n).

malloc returns uninitialized memory. Calling strcat on the return value of
malloc[2] is a bug.

[0]
[https://news.ycombinator.com/item?id=15045592](https://news.ycombinator.com/item?id=15045592)

[1]
[https://github.com/roecrew/nymph/blob/master/nymph/helper_fu...](https://github.com/roecrew/nymph/blob/master/nymph/helper_func.c#L235)

[2]
[https://github.com/roecrew/nymph/blob/master/nymph/nymph_pp....](https://github.com/roecrew/nymph/blob/master/nymph/nymph_pp.c#L910)

Edited to add the last two sentences.

------
tromp
The code fragment

    
    
        Box **myBoxes = malloc(10*sizeof(Box));
        Box *myBox = malloc(sizeof(Box));
        myBoxes[0] = myBox;
    

looks like it should have used 10 times the size of a Box _pointer_.

~~~
nymph019283
Thank you for that catch!

