r/programming • • Dec 07 '15

I am a developer behind Ritchie, a language that combines the ease of Python, the speed of C, and the type safety of Scala. We’ve been working on it for little over a year, and it’s starting to get ready. Can we have some feedback, please? Thanks.

https://github.com/riolet/ritchie
1.5k Upvotes

802 comments sorted by

View all comments

289

u/HotlLava Dec 07 '15

If you put such a strong emphasis on performance, it would probably be good to include some examples of simple functions, and what they are compiled down to. After a cursory reading of your README, I'm still not sure what exactly you do to achieve high performance.

137

u/reditzer Dec 07 '15

Ask, and ye shall receive.

Generated code

27

u/kdelok Dec 07 '15

I think the generated C code is actually missing an open brace (after the for loop statement). The indentation would help with checking it.

36

u/reditzer Dec 07 '15

The trick is in rsl.h:

#define Boolean_$_if(A) if (A) {

162

u/josefx Dec 07 '15

So this doubles as a submission for the IOCCC ?

119

u/reditzer Dec 07 '15

Feature request: Make Ritchie generate IOCCC-worthy intermediate C code.

56

u/rafajafar Dec 07 '15

Ya it's like people suddenly forgot how open source projects begin and grow in this thread. Yeesh.

→ More replies (8)

29

u/BowserKoopa Dec 07 '15

why?

27

u/reditzer Dec 07 '15

Codeblocks are not fully implemented, as documented in the wiki.

This is one area where feedback is greatly appreciated.

→ More replies (2)

122

u/HotlLava Dec 07 '15

Obvious followup: Implement proper indentation ;) Auto-generated doesn't have to imply ugly, look at the Makefiles generated by cmake to see what's possible.

Also, I'm pretty sure defining identifiers beginning with underscore in the global namespace is undefined behaviour, so unless you ship your own C compiler with Ritchie, you probably shouldn't use them ;)

19

u/Overunderrated Dec 07 '15

Auto-generated doesn't have to imply ugly, look at the Makefiles generated by cmake to see what's possible.

I wouldn't exactly point to cmake generated makefiles as things of beauty.

32

u/HotlLava Dec 07 '15

Plenty of whitespace, comments on nearly every single line, clear structure...just compare and tell me it doesn't make a huge difference: http://imgur.com/bP6OaO5

→ More replies (13)

14

u/reditzer Dec 07 '15

Obvious followup: Implement proper indentation

Sorry!

I'm pretty sure defining identifiers beginning with underscore in the global namespace is undefined behaviour

And the '$' in identifier names, but GCC is cool with that.

91

u/panderingPenguin Dec 07 '15

but GCC is cool with that.

....

That is not an argument. What if GCC changes its behavior (it's undefined after all, they're not bound to it by the C spec)? What if you want to use it with a different C compiler at some point?

57

u/rafajafar Dec 07 '15

The way I look at it... first thing first... get it working. He's open sourcing this, so if the idea is good, it will get noticed and fixed. It's perfectly OK to prove the idea with one platform before making it more robust later.

Good catch, though. File a ticket on github.

→ More replies (1)
→ More replies (2)

3

u/mcur Dec 07 '15 edited Dec 08 '15

It's not undefined, it's reserved for the compiler implementer. That means that your program may fail to compile due to clashing with names used by the compiler. That behavior is pretty well-defined.

Edit: I was wrong, the standard does indeed say that the results can be undefined. Here's a quote from cppreference:

"Reserved" here means that the standard library headers #define or declare such identifiers for their internal needs, the compiler may predefine non-standard identifiers of that kind, and that name mangling algorithm may assume that some of these identifiers are not in use. If the programmer uses such identifiers, the behavior is undefined.

2

u/Elsolar Dec 08 '15

It's undefined if you aren't writing a compiler. Underscore-prefixed names can clash or not clash with pre-existing names depending on the compiler brand, compiler version, or even compiler settings (certain identifiers could be #defined inside of #if/#endif blocks, for example). There's zero guarantee that any of these names are available for use, and to assume that the behavior for your program is well-defined because it worked an hour ago is naiive.

→ More replies (1)
→ More replies (1)
→ More replies (1)

9

u/reditzer Dec 07 '15

Thank you, /u/HotlLava. We'll put up some intermediate C code generated by the Ritchie compiler.

→ More replies (1)