可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
For people out there using Haxe, what makes it useful for you? Reading the website it looks very promising. Does it provide significant portability?
What are some real world and perhaps under appreciated advantages?
What are the pitfalls or gotchas?
回答1:
Is Haxe worth learning?
The short answer is: Absolutely!
For people out there using Haxe, what makes it useful for you?
If you're a web developer, you know you can't stick with a single technology for too long. Sooner or later you'll have to deal with changes in the environment or targets (you develop for .NET but an important customer requires PHP, or maybe that widget should be in Flash not Javascript), and this is the best case scenario. In the worst case you'll have to switch constantly, often multiple times in the same business day.
Those switches can waste a lot of your time because you need to change your programming paradigm too many times and possibly because you will have a lot of overlaps in coding your libraries for specific targets. Haxe tries to ease the pain of transition by having just one source language (the Haxe language) and many outputs (through the Haxe compiler). The language is very friendly and quite easy to learn, no matter your background.
Reading the website it looks very promising. Does it provide significant portability?
The language is the same no matter what platform you deploy to. So you define classes/interfaces/enums/typedefs in the same way for JS, Flash, C++, etc. If those types you define do not depend on a specific platform API, they can be reused from platform to platform with no effort at all. All the platforms also share common APIs like XML access, HTTP connections and reflection. Platforms that have things in common (i.e. Neko and PHP) share the same API for things like file access or web-server development.
What are some real world and perhaps under appreciated advantages?
- If you are experienced with Flash/Flex you know how the compiler can slow down your work (the only advantage is being able to take a coffee break while waiting ;) ). The Haxe compiler is many times faster, so fast that most of the time you don't even notice it working.
- The bytecode produced is much faster than the equivalent produced by Adobe tools.
- Also in the Flash realm, Haxe can "inline" functions or access the Memory features that are only available elsewhere by using Alchemy.
- In case you need it, you can also decide what version of Flash to target, from 6 to 10; the API has changed a lot but the Haxe language is exactly the same.
Talking about the server side, we all know how ubiquitous PHP is. You can develop an application with Haxe targeting it and scale to Neko or even C++ if your web application grows.
What are the pitfalls or gotchas?
Here's a list of common misconceptions:
Haxe is young and immature
Not really, Haxe is almost 4 years old now, has seen 25 formal releases (not builds) + 13 alphas and betas, it is updated constantly and has a very dedicated community. It is used professionally by a lot of people in several development areas; take a look at the mailing list archive to find how people use Haxe.
Haxe is complicated
Because the main target of Haxe is without any question AS3, people expect that it must have wizards or a GUI. As stated Haxe is a language and a compiler which makes it suitable for programmers but not very good for designers.
There aren't any IDEs
The true part of this is that IDE could be improved in a lot of aspects to better integrate with Haxe but there are already a lot of valid options.
The only book published is already outdated
There is some truth here too, unfortunately the book was published just a few months before a major release occurred (from V1 to V2). That major release didn't change much, but it did add a few incompatibilities. The book still remains a valid resource (I'm not just saying that because I wrote it ;) )
回答2:
"For people out there using Haxe, what makes it useful for you?"
As a creative flasher I really don't see the point in AS3 anymore! So from a Flash user coder/artist here is my take:
On my current project I have a 19-year old who moved from mostly timeline AS2/AS3 to Haxe classes under my guidance, and was porting both AS2 and AS3 code across. So I don't think Haxe is any more difficult to use than AS3 or when used in Flash significantly different. As far as stability goes, my main current gripe is aspects of the current Flash players, Haxe really is as stable or more stable than AS3 when developing Flash.
Flash evolution has been a constant process of creating libraries that become useless as Flash changes (could it be they need to sell software every year!?), and components have always been something I need, but sizes are silly, so I am not willing to follow like sheep into Flex or even move to the alternative XAML.
The main advantage of Haxe is, that you can start to really think of creating classes that are divorced from platform and will be largely usable five year from now, I doubt that is true of any AS3 you create, Haxe has less tie ins, potentially I could compile code to JavaScript, Silverlight, or whatever Google brings out next.
My main problems with Haxe are that most of the development has been not on Macs so aspects of compiling C++ and new features of Haxe sometimes trail from Windows users, but I have not had problems with core Haxe such as Flash compilation.
In terms of designers: I use a Flash IDE movie loaded at runtime for my visual assets and do the same when developing in AS3 so really my workflow does not depend on AS3/Haxe, I like a simple life so I use Textmate for either AS3 or Haxe. I have a passion for the Flash IDE and its power but would never use it for code and most of my Flash work is largely code, so I am not some Linux hardcore, Haxe does not stop you using Flash IDE, but if you want to use swfmill or sam you can.
The question is: why waste your time on a commercial language AS3 that is likely to change just to sell future versions and is limited to the Flash player?
It has not taken me long to get to a stage where I could create a game or complex ide in javascript without needing jQuery etc just out of the box Haxe... it would work cross browser etc... Haxe lets me take my Flash programming skills and interface development understanding outside flash (having never really used JavaScript before), if I was to learn pure JavaScript I would probably not feel so enabled, more like someone had cut my arm off and I would be writing very platform-specific code, while now I can use FEffects for tweening and later add some compiler switches and compile to some other platforms and use some neash/nme.
I actually quite like aspects like the compiler being smart about types, allowing my code to be cleaner. And typedef's are brilliant.
I looked at PHP and decided it was a messy silly dirty language and same for JavaScript, I am so glad I can target them with Haxe and not have to spend too much time on black hack magic.
If you love to create code for rapid dev of visual creativeness, I think Haxe is the ideal language and even as a freelancer I am using it commercially.
回答3:
My view of Haxe,
Warning the following paragraphs are very philosophical (Practical ones are further down):
As someone who has been open to many programming languages over my short time programming and someone who simply moves on when I feel something isn't working for me; I find that Haxe is something that I just can't progress from, I just cant 'better it'.
I had found in the past that the amount of time I spend writing in one particular language relates to two key factors, how much I need to use that language to get the result and how easy I find that language to grasp. But with Haxe the grasping period was much shorter, and I attribute this to my small build-up of knowledge in a variety of languages. Until Haxe I had never found one that really suited me and that just felt right, they were either to hard to understand or just plain useless; well at least useless from my perspective.
Haxe had allowed me to be a lot more expressive with how I write, I don't mean the 'expressive' as in the quality that everyone talks about languages having I meant the ability to just have an idea and run with it, to try something out the way I feel is right. Whether it succeeds or totally fails.
Haxe has been a very easy learning curve for me, with my general background in c style languages and AS2/3, and I have not really had any trouble picking it up. One thing that always stymied my progression with a new language was understanding the concept behind that particular syntax/framework, but even once I had passed that hurdle I would often find that the language was in itself either limited, limiting or both. With Haxe I'm neither limited nor am I finding the language itself to limit me. With Haxe there is no glass ceiling, but the is a glass floor, in that there is no limit to what you can do but you can clearly see how you got there
Picking up Haxe isn't like picking up some sticks and making fire, but nor is it like going out and buying a oxyacetylene set and starting a fire with that. In that sense Haxe is closer to a match, that you can reuse. It follows almost all of the conversions of something that your used to but adds useful new features. But to do so it doesn't reinvent the wheel entirely, it just fixes the rotten bits. (ok fewer analogies in the next paragraph)
Practical things:
The language is simple easy and standardised, whilst still allowing the programmer to go as far as they like.
Your can write a very high level piece of code or go and fiddle with the little bits and pieces (to a serious degree on some platforms)
Haxe doesn't dictate what you can and can't do on any one platform, it gives (or plans to give you) full access to everything, but where it can it adds a standardised way of doing things.
The mailing list is very helpful and responsive and the forum is even picking up pace now.
The language is constantly being changed (in minor ways) with new things added in every release.
There are very few real bugs coming through for the main API and even fewer for the compiler.
Every one talks openly about the language its direction and the direction they suggest for Haxe (and or course why it should take that direction)
And finally Haxe isn't some big private venture by a large (or even small) company to make money out of you as a developer, instead it is created for all developers to use, build upon and improve. And that is why I feel Haxe is where I want to be. (now to go back to coding)
回答4:
If you want to have a short answer: YES!
For people out there using Haxe, what
makes it useful for you?
The most of the time I use Haxe for the server side. (This means PHP or neko target). In my opinion PHP is the most sucking language I ever used, that was the reason I started using Haxe: Having a useable language.
Another big advantages for me is, that Haxe is open source.
Does it provide significant portability?
Having the same code on different targets! I could not imagine any way to have more portabillity.
Migrating a website from PHP to mod_tora, which performs 40-80 times faster then PHP, oftens just requires 5 minutes of work???
What are some real world and perhaps
under appreciated advantages?
- The biggest advantage is portability of code and the excellent options to communicate between the platforms, it was never easier to handle data between client and server. (Take a look at the Remoting section in the wiki.)
- The community is great. (If you like mailing lists at least. :-)
- Another thing is: If you need to perform very platform native operations that are not supported by Haxe (which happens very seldom), Haxe always gives you the options to target them. It's called the Haxe magic. In other words: you could to everything you could do in the native language of the platform + all the nice thing Haxe offers you.
What are the pitfalls or gotchas?
- Documentation, sometimes installation are not 100% perfect. The support for IDEs could be improved a lot.
- Also the JavaScript target is sometimes hard to use, because Haxe provides a really good language, but some kind of framework for the most common DOM manipulations is missing, but I think some people are working on that ;-)
- If I have to work for clients they sometimes dislike the idea to have their project realised in such a unknown language.
P.S.: I think it always worth to learn a new language, as it improves you programming skills and experiences.
回答5:
Well your question is already answered but I'd like to add a few short blurbs.
I learned and used Haxe entensively after the first betas and have been using it ever since.
It was the first language I learned (I was also still in college at the time) that really made me understand the difference between language and API.
You see at college I first learned AS2, then PHP, then some Javascript. We had no formal introduction to programming (and I wasn't studying computer science anyway). These languages are all pretty tied to the platforms so as a newbie programmer I automatically assumed that things like strlen() is PHP, MovieClip is AS2, ...
By using Haxe I actually understood the value of object oriented design, since the platform was no longer restraining my classes. I could reuse code written for a Flash project in my regular web code, if I seperated them from their platform specifics well enough.
Because of the excellent remoting classes you can use to communicate between platforms, I also realized XML isn't all that special, nor is JSON, it's all meaningless without code that acts upon it.
For someone like me who just started programming, that was a pretty big revelation in a time when XML was 'cool' and good for everything ;-)
回答6:
Haxe is an invaluable language. Many of it's plus-points are often overlooked. For example, it has fantastic built-in libraries that make application development sooo much easier, such as a simple but very powerful ORM (Neko/PHP), full cross-platform remoting (Flash/JS/PHP/C++/Neko) where any supported platform can communicate seemlessly with any other platform, a solid regular expressions library (support by all except Flash <8) and many more.
As a note, I recently wrote an application using Haxe for PHP/JS/Flash and found the development speed was increased exponentially.
Granted, Haxe might not be designer centric, but it's not hardcore, either. Haxe is very easy to learn and reuse, and as the number of target platforms increase, Haxe developers can target those, too, without having to learn anything new.
回答7:
My primary use of Haxe is limited still to Flash development. I'm only slowly warming to the idea that it can be used for other targets. I still don't see the advantages in that direction and do my PHP and JS directly in PHP and JS.
Even though I don't develop for the Neko back-end it is great support to have since it means I can write test cases for code and have them integrated into a build script rather than only being able to run them in a flash player. This is a very good advantage.
The open nature of the code and development is also a good advantage. I really needed a preprocessor and so #line support was added to Haxe. I don't think Adobe would ever have taken my request seriously.
I find that being a typed language is huge advantage over many of the new modern languages.
There are several of pitfalls with regards to language consistency and back-end transparency. I keep a list of the ones that affect me here. Of course no language is perfect in this regards but I'm kind of disappointed that a new language has so many.
回答8:
Subjectively I find I'm more productive in haxe than any other language. I use haxe mainly targetting neko and javascript.
The compiler itself is very fast which allows me to use haxe like a scripting language. It leans towards object orientation but has a number of functional tools; first class functions, functional match, lambda libraries.
I find the speed of neko sufficient, and it's small image size great for constrained environments. It's C FFI is excellent - very simple to add new functionality.
I use haxe for my javascript client side controller, firing events to a standard jQuery view. This works really well as you can type check your client and server code simultaneously, while keeping untyped raw js to a minimum and retain the benefits of the usual js libraries. JSON libraries available. Btw, although haxe does come with mod_* for apache etc, I find using a proxy much more flexible, so i can set up multiple neko instances behind the web server.
On the whole I think it's very well rounded and thought out - and critically it works as advertised on all platforms.
bd
回答9:
I've been coding Haxe in personal and professional uses for about 2 years. There are certain advantages that it has that you won't get from other languages, the biggest one being that it was designed nearly from the beginning as a modern production-grade compiler that can adapt flexibly to new platforms and take advantage of their unique features. This makes it the closest thing out there to a higher-level version of C. If you write code in Haxe, you can count on it sticking around.
Community uptake has been stronger than you'd think - I did a little analysis of list traffic in terms of compressed kilobytes(from the data on http://lists.motion-twin.com/pipermail/haxe/ ) and the result shows a 25-50% YTD(Jan-September) increase each year since 2006. In the last six months traffic has really exploded and I'm seriously considering going to digest because otherwise my inbox gets flooded with hundreds of messages on Haxe if I leave it for more than a day. It's not as hyped as other languages, but that in turn means that the people hitching their wagons to Haxe tend to be confident, well-informed programmers.
People have experimented with language-to-language compilers in other contexts(Scheme anywhere, Python or Ruby in JS, etc.) but those languages were designed for a different place and purpose, and in translation lose a lot of their best aspects, making the results cool hacks, but not comfortable for day-to-day work. Haxe doesn't feel like that; while it doesn't have the conveniences that come from having language/runtime integration, it has a lot of other cool stuff to offer right now.
回答10:
yes, completely
BUT it needs a better IDE and documentation, the lack of a great IDE (like an eclipse based one) for me makes all the difference, and I cannot reach the levels of productivity I do in other langauges due to this.
language = great - best by miles
development environment = poor (at this time and imho)
回答11:
I had Haxe on the radar since it started. I agree it seems very promising but I noticed that developers are not adopting it as quickly as you would expect (compared with RoR and even Flex).
Regardless how good and suitable Haxe can be for you right now, you will still be among the early adopters and you will sure go into issues early adopters usually face.
Although there is a very active mailing list with very helpful members, I would still wait until more people join in and more books and resources are written about it.
At the end, Haxe helps you write in a single language and target different platforms (JS and Flash mainly, and now NekoVM, PHP, and C++) do you really need that?!