#1047 Some features that I think would make Fantom more popular

tcolar Sun 28 Mar 2010

While I'm way busy with making the Fantom IDE, I keep having ideas of other things I want to do in fantom .... but often I feel a few things are "missing", not from the language, but more tools/API.

I was wondering what other people here think about those, and what other things they'd like to see. I also would like Fantom to become more mainstream and think some of those could help.

I could probably work on some of that, and was also wondering if anybody is working on some of it.

Web Framework Take this one with a grain of salt, I'm not a big fan of the big/large frameworks (like most Java ones, used my own), but if you look at ruby, groovy and even scala, there is no question their associated web frameworks (rails, grails, lift) made their popularity jump drastically. I like minimal frameworks myself, and like Fantom web base ... but I think a simple/nifty "conventional" framework on top of it would be a big plus.

Servlet API I think somebody was working on this (cheeser?), but I think one way a lot of Java people could get started using a little fantom with their existing java base would be to be able to wrap a fantom weblet into a servlet. (dealing with fantom runtime undercover) .... As a long time java guy(ant there are millions of us), I know if you show me Fantom and an easy way to make sue of it, it will be an easy sell for sure ,IMO better sale than groovy(too dynamic) or scala(too hard).

Other targets I think it's really cool that Fan can run on Java and .net, even though that's a bit of a platform overlap, and it's even cooler it can do javascript, but I'd like to see some other impl. One I'd really like to see, would be to be able to compile for the iPhone(objective C) ... not sure how easy that would be (probably not too easy, but haxe does it), but I swear out of the thousands of iPhone/iPad peeps devs out there, I can't be the only one not excited about using ObjectiveC.

Anyway, just throwing some ideas.

jessevdam Mon 29 Mar 2010

If I can help you with the IDE let me know.

It seems that your fantomide.colar.net is down (dns not working).

brian Mon 29 Mar 2010

All great ideas tcolar.

I think one or more web frameworks would always be welcome. Although I think where Fantom shines is when you build your web UI in Fantom itself as JavaScript in the browser. In this case you backend tends to be very simple. So the "framework" tends to be more of a client side thing, then a server side thing.

Targeting the iPhone is something I've thought about too. Although I suspect targeting Android might be a better long term play. It already has a JVM and is probably more of a target for Java community. Plus die hard iPhone app developers will probably want to stay close to the metal. Personally getting Fantom up and running on Android is probably one of the top projects I'd love to see someone tackle this year.

tactics Mon 29 Mar 2010

To be rudely technical, Android doesn't actually run on the JVM. Google wrote a custom VM called Dalvik to better meet the needs of the limited hardware. It's a register machine. Currently, it has no JIT support.

Supposedly, Google wrote Dalvik in order to get around certain licensing restrictions on the JVM that prohibited use in mobile devices.

The software for Android, though, is written in Java. The toolset compiles the Java code down to a normal jar, then compiles it further to a Dalvik package called a .dex file. Dex files are similar to pods in that they share a common constant pool (as opposed to Java, where every class has its own pool). The dex file must also be signed by its author (though it need not be registered in any CA).

Given all of this, there are actually a few options for targeting Android. The first and most naive way of doing it would be to use the jstub tool to output a Java jar for a pod, then run it through the Google toolchain to compile it to a dex file.

Second, we can explicitly target the dex file format. This would be a much more direct conversion (I really dislike Android's fat toolchains). It would require that we do a stack->register bytecode conversion, which we're not quite ready for yet. (doing this conversion is tied to the method stack size analysis, which isn't implemented yet). We might also need to tweak the runtime a bit.

One last point -- space is limited on phones and we don't want a user to have to install multiple copies of the Fantom runtime -- one for each Fantom application they install. I don't think sharing code is especially trick on Android (I heard it's a pain in the ass on the iPhone), but it's something else to consider for phone backends.

Personally, I think Fantom on Android would be amazing. I don't know if it's how Google flows, but their API for Android is as terrible and bureaucratic as anything else in Java. You would think that limited resources meant there wasn't enough space for a ContextManagerFactoryObserver, but the Android API is filled with the things.

andy Mon 29 Mar 2010

Although I think where Fantom shines is when you build your web UI in Fantom itself as JavaScript in the browser. In this case you backend tends to be very simple.

Undoubtedly this is a major feature of Fantom - tho one of the major features of Rails is ActiveRecord - which has no equivalent in Fantom at the moment. Given the worlds reliance on relational databases - that would be a great project.

On iPhones, etc - I don't think getting Fantom running there is necessarily that valuable - since the value in the those platforms is in the platform toolkits like UiKit.

So I'd say the most bang for your buck here is in an ORM solution for those like that sort of thing - and better (read: easy) integration into Java ServletContainers.

brian Mon 29 Mar 2010

Great comment tactics. I personally think Fantom on Android is probably one of the most important projects we could kick off. Phones are really hot platforms today, and Fantom was designed from day 1 to target embedded devices, so I think there is a great fit.

tactics Mon 29 Mar 2010

Palm's WebOS might also be an easy target for Fantom. And we'd have a MUCH easier time than most languages. WebOS apps are written entirely in Javascript and HTML.

KevinKelley Mon 29 Mar 2010

Android

Fantom on Android would be really interesting -- I agree about Android toolchain being a fat, piggy pain. I don't know how to get there, though.

UI is the big deal, I think: getting to Hello World on a platform is a milestone, but most projects then die because the framework story doesn't fit. Android would be cool, but I'm not seeing, yet, how the story goes: Fantom runtime compiled down to dex; a layer of Fantom wrapping the framework? Maybe an analog of FWT that fits/simplifies the android life cycle framework? This seems to me like it'd take a bunch of engineering/architecting; not so much a hobby-project: needs more resources than I'm aware of here.

LLVM

I've skimmed through LLVM several times; the path Fantom fcode => LLVM bitcode doesn't seem like too much of a mismatch, but what would be the point? For me, anyway: I don't do Apple, so the ObjC target helps me not; targetting to C and compiling to an application would be neat, but any desktop machine these days already has a JVM, so just going straight Fantom on JVM is a lot simpler. And Fantom runtime is mostly implemented in Java (and in parallel in C#), so targetting standalone apps would mean lifting the runtime into Fantom and/or building another parallel runtime in, say, C++. (Lifting the runtime implementation into Fantom really ought to happen sometime, btw, imho :-)

Webapp

The "Web 5.0" I'll call it, web-apps running in JS with HTML5 features like local storage to make the apps more platform-like. Fantom's looking great for this, and apparently Brian and Andy are already going there, to good effect. Lots of good possibilities here: since just about everybody from phones on up is moving toward webkit-like browser with decent JS, you can use Fantom => JS to build run-anywhere apps. Lots of room for growth and improvement, but this is a good story for Fantom.

Web server framework

This is the ripest unplucked fruit right now, I think: Fantom's got all the pieces ready to go, you can throw together a webserver with hardly any effort already. But there's a lot of desire apparently for a framework that puts it together into a "download, setup, tweak, add content, deploy" path.

There's momentum here on a couple related fronts: Seaside, in Smalltalk, is coming to a 3.0 release and is looking good, has sub-projects Comet, Pier, Magritte, and so on that do CMS (simple wiki for ex.) and ajax and javascript stuff.

And in Clojure there's a bunch of activity with Ring, Compojure, various projects doing webserver stuff running generally on servlet containers like Jetty/Tomcat/etc.

So, lots of apparent desire for solid, scalable, easy-to-build and -manage web server stuff. We really, seriously, need to be here with a good story of our own, I think: it's so much a Fantom strength, but we don't show much evidence of people actually doing it.

Anyway, sorry to ramble. Good discussion. Carry on. :-)

liamstask Mon 29 Mar 2010

I just wanted to voice some interest in an LLVM/C++ runtime - I'd love to get Fantom running on the ever cheaper and more capable embedded platforms coming out these days. Would much prefer this to the JVM in that case. Something like Poco/Boost/Qt could make it pretty easy to implement the native parts of the Fantom std lib.

And definitely agreed on the ORM/web framework issue - this probably requires the least effort of the initiatives listed here, and could provide some of the widest exposure/utility.

tcolar Mon 29 Mar 2010

Great, thanks for all the comments, nice to see everybody's take on it, keep it coming !

Wanted to say I find Fantom's language and base API's near perfect at this point, and that's kinda why I'm thinking more "big picture" now and why I posted those comments.

@jessevdam Thanks, i just switched dns provider and had forgot that subdomain (it's back up now), as far as helping on the IDE, I'll let you know if new features come up, the stuff I'm in the middle of, it's probably best i wrap it up (it's getting there, I've had limited time lately).

On web framework @brian You are probably right about "I think where Fantom shines is when you build your web UI in Fantom itself as JavaScript in the browser", I'm not use to think of a web framework this way yet, but this is definitely really cool and I think web dev. is going this way. It could really use a "real" project / demo (with sources avail) that shows it's power though.

I don't think it precludes from also having a bit more of a framework on the server side as well however, but like @KevinKelley said, Fantom as the pieces it's probably just a bit of putting it all together. I might be able to work on this later on as this is an area I'm most familair with.

IPhone / c++ The reason I mentioned the iPhone is not because I'm in love with Apple (truce is I like using their product, but not developing for it, or their business practice), but because of the sheer volume of developers(trying to make a buck) it has compared to the other mobile devices, meaning more spread for Fantom.

I'm a blackberry user and there is no doubt making Fantom work on a JVM based device such as the blackberry or android(kinda) would be way easier than the iPhone.

@liamstack I actually did not realize what LLVM really was until now, but it seem it would be nice to havce (lots of potential targets).

ORM There is no question an ORM is kind of a must have nowadays, even though I always thought of the whole active record thing to be way overblown(ie: scaffolding).

I wrote a basic one in my own framework(even use it in the fantomIDE) but I have to say it's not an easy task and hard to maintain - if you think javascript incompatibility across browser is a pain, try SQL acrosss dB's-, so I'm not aure about the "least effort".

Now of course databases seem to change a lot lately(for the better) and maybe we could just go straight for non-relational DB's ?

Either way I agree it's probably the #1 thing missing right now.

tactics Mon 29 Mar 2010

Android

I totally agree about the Android target not being simple. There is a ton of design space to be considered. We'd have to make some hard decisions about how much of Android we expose.

Do we model the component architecture? Android breaks apps down into components: Activities, Services, Broadcast Receivers, and Content Providers. Each has a different lifecycle. They can be shared among other apps.

How do we model resources? Android heavily relies on a custom XML resources for UIs. It also does Magic on XML resources, converting them to a smaller binary representation. (Again, Android's toolchain is fat).

Then there's the issue of how Fantom Android apps are stored. I believe it's possible to have a single Fantom app, which is just a modified sys pod. Then, the app probably needs to expose itself as a Service component to grant the runtime to the actual Fantom apps. Fantom pods should probably be pre-compiled to Dalvik bytecode so that the runtime doesn't need to mess with outputting bytecode.

So yeah. Fantom on Android. Cool, but technically challenging.

LLVM

A native runtime for Fantom is my #1 dream. The biggest benefit is it would provide direct access to native libraries. Linux has so many cool libraries with either a crappy or no Java port. Secondly, it would load much faster than the JVM. Right now, Fantom is great for writing servers and long-running applications, but it takes a while to start up, and so it's a poor choice for writing pipe-able Linux-y utilities. (I once made the mistake of calling fan -pods to do bash auto-complete. It did not end well).

@KevinKelly What did you mean exactly by "lifting" the runtime into Fantom? I realize between the JVM, CLR, and JS implementations, the sys pod is pretty redundantly redundant. Did you have any other ideas on how to DRY it out?

KevinKelley Mon 29 Mar 2010

What did you mean exactly by "lifting" the runtime into Fantom?

Just, going through the Fantom apis and everywhere possible, taking the java implementation code and writing it in Fantom. As it is now, most or nearly all of sys pod is stubs in Fantom, and actual code written in Java (and C#, and again in JS). Porting to another platform means writing it all again, porting the java/c#/js implementation to the new platform. What I think we need, at least at some point, is a "reference" implementation, written in Fantom itself, of Fantom.

Quite a few sys pod classes are native implementations for obvious reasons: they're a thin shell on functionality that Java already has. But there's quite a bit of stuff that's Fantom-specific, with no particular reason it needs to be native code.

Obviously there has to be some native code, to access the features we need. But I think it would be good if as much as possible of Fantom runtime were written in Fantom itself, and the low-level platform-access kept to a minimal core. (Probably can't be an actual separate "core", but, running a search through all pods, types and slots, for "native" implementations, should return a minimal set of things that actually need to be natively implemented.)

Having the Fantom JVM runtime be written in Java, as it is now, might be good for efficiency reasons, but that should be an implementation detail: the official, reference implementation of Fantom ought to be in Fantom. There's always a trade-off; we get a lot of stuff for "free" by stealing it from Java. The down side is that, until it gets lifted (re-written in Fantom itself) or re-implemented again in all the other platforms, it locks code that uses it to the JVM.

MoOm Mon 29 Mar 2010

I've been working on implementing an LLVM backend for Fantom for some time now. I have not been able to spend as much time as I'd like on this project, so it's still in a really early stage and cannot run any sample code yet. I'm currently still focusing on implementing the essential classes of the sys pod in C, so it can be called by the generated LLVM bytecode.

After having a working LLVM backend that could JIT and compile Fan code to native apps, I'd like to do the same for the ActionScript3 virtual-machine, so Fan could be used to build .swf files.

With those two backends, the next nice thing to have would be a common graphics/audio/UI API so we could use Fan to create applications/games that would literally run everywhere: iPhone, desktop and console applications would be possible via the LLVM backend, Android applications would run on the Dalvik VM via the Java backend, Web applications could use either the Flash backend or the Javascript/HTML5 backend. The dotnet target could eventually also be used to produce Silverlight and Windows Phone 7 applications.

With all of these, Fantom would definitely be the ultimate language to create graphical multi-platform applications! :)

katox Tue 30 Mar 2010

Very interesting discussion! Just a few remarks

Android

@tactics Android JIT is on its way. But this would only help Fantom. The simplistic solution you outlined actually doesn't seem that bad. Droids have recently caught up with iphones in sales so this is probably the best open market. I think availability of Fantom on Android devices might force me to buy one ;). But if I'd have to use some sort of "foreign" APIs it would be a bit lackluster.

LLVM

+1 on this one. I have to do lots of (server side) scripting and Fantom is a good tool for that - only that JVM startup is killing it.

RDBMS

Unlike some people here I don't think ORM is low hanging fruit. I also don't think than many people miss Haven that much. A simple API aka JDBCTemplate would do the job as well. Having dynamic types would help here but then again it is a general language feature.

NoSQL

Or should I say cloud? I think this is a big one. There is already some native support, at least @liamstask's MongoDb driver.

Web

There are tons of web frameworks and development complexity is hideous. I don't think Fantom really needs something like Rails or Lift - it wouldn't catch up. Better to focus on JS->DOM approach - a Sidewalk like example would definitely help Fantom's popularity gain. I've met people on IRC who tried this path but they eventually gave up.

It is pretty hard to try to learn Fantom and js+dom+rest+(a bit of)web approach at the same time.

Maven/APT

Integrated build system is great but there is no popular 1.0 without a cloud repository. Most pieces are already in place but there is a lot of work to be done. Besides there is a lot to be decided on the overall design, I fear. Loads of failed or abandoned projects to be (waving to maven) prove this rather well.

Fantom -> Java

I tend to overlook this one but it seems it is pretty important for people to be able to sneak Fantom snippets into Java codebases ;).

Releated Work

Fantom site should maintain a list of sub-projects, related and ongoing works, discussions and IRC rather visibly. While forum is great developers need to know more. I know I'm repeating myself on this one but I still think it is quite important.

katox Fri 30 Apr 2010

As nice writeup of ruby on android. A lot of those things indirectly apply to Fantom too.

"The other complication is that jrubyc normally outputs a .class file of the same name as the .rb file, to ease lookup of that .class file at runtime. So the main .class for the above script would be called "foo.class". The problem with this is that foo.rb may not always be loaded as foo.rb. A user might load ../yum/../foo.rb or some other peculiar path. As a result, the base name of the file is not enough to determine what class name to load. To solve this, I've introduced an alternate naming scheme that uses the SHA1 hash of the actual content of the file as the class name."

Login or Signup to reply.