Hacker News new | ask | show | jobs
by srean 4605 days ago
For the early adopters and experimenters amongst you, you might like Felix http://felix-lang.org/share/src/web/tutorial.fdoc

It is a whole program optimized, strongly typed, polymorphic, ML like language that can interact effortlessly with C and C++ code and has coroutines baked in. Its own demo webserver is based on coroutines. It uses a mix of lazy and eager evaluation for performance and compiles down to C++. Execution speed is comparable to C++, mostly better. Its grammar is programmable in the sense that it is loaded as a library.

With inaccuracies in analogies assumed, Felix is to C++ what F# is to C# or to some extent Scala is to Java.

It is also mostly a one man effort but with a feverish pace of development so it comes with its associated advantages and disadvantages.

Tooling info is here http://felix-lang.org/share/src/web/tools.fdoc

The author likes to call it a scripting language but it really is a fullfledged statically compiled language with a single push button build-and-execute command. http://felix-lang.org/ The "fastest" claim is a bit playful and tongue in cheek, but it is indeed quite fast and not hard to beat or meet C with.

4 comments

Hrm, what do you think about rust vs Felix? They seem to be targeting the same problem.
Rust and Felix both try to be general languages so they're both targeting that. Felix has a better type system. Rust provides more secure but restricted protocol for concurrency, Felix has no such restrictions, it's specifically designed to support shared memory concurrency, which Rust specifically doesn't allow. Rust uses message passing but organises via the memory management mechanism to do it very fast.
Note that Rust does allowed shared memory, either via "unsafe" code (i.e. same flexibility & dangers as in C, but the compiler only accepts it when wrapped in an `unsafe {}` block, so it's clear that you need to be careful), or higher level wrappers around this like Arc[1] for immutable shared memory, or RWArc[2] & MutexArc[3] for mutable shared memory.

> Felix has a better type system

What do you mean by this? From what I can see, the only way Felix encodes any form of memory safety (e.g. dangling pointers) in the type system is by garbage collection.

[1]: http://static.rust-lang.org/doc/master/extra/arc/struct.Arc....

[2]: http://static.rust-lang.org/doc/master/extra/arc/struct.RWAr...

[3]: http://static.rust-lang.org/doc/master/extra/arc/struct.Mute...

I have to delegate that to John (Felix's author) not much of a language theorist myself. It seems to me that Rust wants to be the better/safer C replacement. I think Felix's sweet spot is at a slightly higher level. For example, Felix's garbage collector can indeed be avoided for lower level code, it was meant to be used as an optional feature, but to me it seems it requires more than superficial knowledge to avoid it successfully.
I had a look at it and it sounded pretty cool. The one thing I found unfortunate is the lack of separation between safe and unsafe code, but it certainly has a lot going for it.
There's no such thing as safe code. So to do as you suggest requires some set of suitable concepts of relative safety, together with some way to enforce them. I am very interested in implementing mechanisms that provide guarantees. And not just safety. Another would be licence management (e.g allow only BSD licenced code to be used) .. that's a legal safety guarantee :)
Yeah, that is D's strength, that and compile time function execution.
This looks really awesome! Thanks for bringing it to my attention. Why is this so much under the radar? It seems like it would have a ton going for it.
The historical answer is that originally Felix programs were being written for the Shootout and the compiler was upgraded so it performed well. In fact it trashed everything. Then control of the Shootout changed hands and Felix got dropped by the new manager. Today, there are no forums for developing new languages.

Felix "targets" people that would like to use Haskell or Ocaml but have a ton of code in C and C++ to interface with. Felix is a C++ upgrade: it discard the syntax, but retains ABI compatibility, at quite some cost to things like safety for example.

Felix is more or less guaranteed to perform on par with C/C++ or better for the simple reason you can embed C++ directly into Felix, this works because Felix generates C++. And of course you can link to your favourite libraries with minimal syntax.

  type mytype = "My::Type";
  ctor mytype : int = "My::Type ($1)";
  fun addup : mytype * mytype -> mytype = "$1.addup($2)";
Unlike Ocaml which requires a lot of hard to write glue logic, Felix and C++ share types and functions. Typically only type glue is required to create a bridge.
No forums for developing new languages? Seems like Go, Nimrod, Rust, D, CoffeeScript and many other relatively new languages have large and active development.

That's interesting that they were booted from the shootout. I wonder what happened there. Anyway, I haven't really looked at this enough to see how its features really play out, but on the surface it looks great. Certainly as an alternative to C++ it sounds miles ahead, and indeed many of the languages being developed today are intended precisely as alternatived to C++. A guarantee of C/C++ performance or better is very enticing. :)

I think skaller meant that there is no common shared forum for (new) languages. Well, there is LTU but the discussion there tends towards the theoretical side, its focus is language implementers rather than language users. The language game site used to be one place a user could get exposed to different languages. It has largely become autocratic, arbitrary and "dont tell me how to spend my free time"hostile in the sense language gets dropped from the list for no clear reason. I think it has stopped being the de facto go to place for language comparison as well, not sure of the latter.
Lack of marketing I guess, not many users, and may be because people panic when they cannot immediately find the thing they are familiar with, for example OO hierarchies, dynamic types. Plus I found it hard to understand till I got a rudimentary understanding of OCaML, and Haskell's typeclasses. So its not ready to be used by everyone.

To do something nontrivial with it you would need to be on the mailing list though.

@dllthomas as far as I know OCaML doesnt, by no standards am I an OCaML user, although want to get better.

OCaml doesn't have typeclasses, does it? It's been a while since I've used it, so things may've changed or my memory may be failing...
It now has first-order modules, which can be used to accomplish almost the same thing. The biggest difference is first-order modules are explicit while typeclasses are implicit. Whether this is a good or bad thing is up for debate.
It had first order modules when I was using it, but people may well have found uses for them that make the comparison more apparent.
> compiles down to C++. Execution speed is comparable to C++, mostly better.

Uh, what. Can you clarify?

This seems counter-intuitive to people who don't write compilers, but a language that compiles to C++ can perform "better than C++" because it can emit code that no human would bother writing, usually taking advantage of information available in the source language that couldn't be safely determined by the C++ compiler alone. Whole program optimization, for example, allows you to do a lot of aggressive reorganization of code that would be very ugly if done by hand (think of putting all your code in one file and putting everything in an anonymous namespace).
Then say "better than hand-written C++", not "better than C++". It's like saying "C++ performs better than assembly". No it doesn't. It may perform better than hand-written assembly, and that's completely different.

It's just annoying when people will do anything to get on the "faster than C++" wagon.