5 lines of code

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

5 lines of code

singmajesty
Everyone probably knows about the infamous "Hello World" sample for  
Google's Dart language, clocking in at a hefty (and astonishing!) 17,259  
lines of code (http://t.co/YFucTkBW).

Following that fiasco, Justin Donaldson tweeted his "Hello World" sample  
for haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).

Earlier this evening a challenge came in by way of CoffeeScript, compiling  
a "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).

Well, I am happy to say that haxe was not one to be out-done. Winning the  
"crown" for "Hello World" compiled code, here are haxe compiles for 7  
lines of code (http://t.co/HTuqKnOl) and 5 lines of code  
(http://t.co/KiCMnfRq)


Of course this is all silly competition, but just in case you were  
wondering whether haxe was cool enough or not ;)

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

Viktor Hesselbom-2
What compilation parameters did you use for this result? Did you write your own javascript target? Or did you strip out manually all unneeded code? :P

viktor hesselbom



2011/10/14 Joshua Granick <[hidden email]>
Everyone probably knows about the infamous "Hello World" sample for Google's Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of code (http://t.co/YFucTkBW).

Following that fiasco, Justin Donaldson tweeted his "Hello World" sample for haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).

Earlier this evening a challenge came in by way of CoffeeScript, compiling a "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).

Well, I am happy to say that haxe was not one to be out-done. Winning the "crown" for "Hello World" compiled code, here are haxe compiles for 7 lines of code (http://t.co/HTuqKnOl) and 5 lines of code (http://t.co/KiCMnfRq)


Of course this is all silly competition, but just in case you were wondering whether haxe was cool enough or not ;)

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

singmajesty
I used a macro :)

I have --macro CustomGenerator.use() in my compiler parameters



On Fri, 14 Oct 2011 00:51:35 -0700, Viktor Hesselbom  
<[hidden email]> wrote:

> What compilation parameters did you use for this result? Did you write  
> your
> own javascript target? Or did you strip out manually all unneeded code?  
> :P
>
> viktor hesselbom
> www.hesselbom.net
>
>
>
> 2011/10/14 Joshua Granick <[hidden email]>
>
>> Everyone probably knows about the infamous "Hello World" sample for
>> Google's Dart language, clocking in at a hefty (and astonishing!) 17,259
>> lines of code (http://t.co/YFucTkBW).
>>
>> Following that fiasco, Justin Donaldson tweeted his "Hello World" sample
>> for haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>>
>> Earlier this evening a challenge came in by way of CoffeeScript,  
>> compiling
>> a "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>>
>> Well, I am happy to say that haxe was not one to be out-done. Winning  
>> the
>> "crown" for "Hello World" compiled code, here are haxe compiles for 7  
>> lines
>> of code (http://t.co/HTuqKnOl) and 5 lines of code  
>> (http://t.co/KiCMnfRq)
>>
>>
>> Of course this is all silly competition, but just in case you were
>> wondering whether haxe was cool enough or not ;)
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

George McBay
In reply to this post by Viktor Hesselbom-2
He basically just used JavaScript directly:

untyped console.log ("Hello haxe JS");


On Fri, Oct 14, 2011 at 12:51 AM, Viktor Hesselbom
<[hidden email]> wrote:

> What compilation parameters did you use for this result? Did you write your
> own javascript target? Or did you strip out manually all unneeded code? :P
>
> viktor hesselbom
> www.hesselbom.net
>
>
> 2011/10/14 Joshua Granick <[hidden email]>
>>
>> Everyone probably knows about the infamous "Hello World" sample for
>> Google's Dart language, clocking in at a hefty (and astonishing!) 17,259
>> lines of code (http://t.co/YFucTkBW).
>>
>> Following that fiasco, Justin Donaldson tweeted his "Hello World" sample
>> for haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>>
>> Earlier this evening a challenge came in by way of CoffeeScript, compiling
>> a "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>>
>> Well, I am happy to say that haxe was not one to be out-done. Winning the
>> "crown" for "Hello World" compiled code, here are haxe compiles for 7 lines
>> of code (http://t.co/HTuqKnOl) and 5 lines of code (http://t.co/KiCMnfRq)
>>
>>
>> Of course this is all silly competition, but just in case you were
>> wondering whether haxe was cool enough or not ;)
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

sledorze
In reply to this post by singmajesty
Does your macro prevent certain class of program from working that would work with the normal Js generator?

Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

Juraj Kirchheim
In reply to this post by singmajesty
As a slight improvement:

@:native('console') extern class Console {
        static public function log(s:String):Void;
}
class Main {
        static function main() {
                Console.log('hello world');
        }
}

On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
<[hidden email]> wrote:

> Everyone probably knows about the infamous "Hello World" sample for Google's
> Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of
> code (http://t.co/YFucTkBW).
>
> Following that fiasco, Justin Donaldson tweeted his "Hello World" sample for
> haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>
> Earlier this evening a challenge came in by way of CoffeeScript, compiling a
> "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>
> Well, I am happy to say that haxe was not one to be out-done. Winning the
> "crown" for "Hello World" compiled code, here are haxe compiles for 7 lines
> of code (http://t.co/HTuqKnOl) and 5 lines of code (http://t.co/KiCMnfRq)
>
>
> Of course this is all silly competition, but just in case you were wondering
> whether haxe was cool enough or not ;)
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

singmajesty
In reply to this post by sledorze
haxe 2.08 includes a macro (thanks for the tip Nicolas!) under  
/std/haxe/macr/DefaultJSGenerator.hx that you can modify to customize your  
JS output.

I knew that the standard classes for Reflect and Type were not needed, so  
I checked "c.name" and only let "Main" get through. If someone wanted a  
"minimal JS" target, I bet it would be possible to embed additional  
"smarts" to dynamically determine whether these standard classes are  
actually used.

I commented out a few lines in the genClass method, since I knew I didn't  
need reflection. That's how it moved from 7 lines to 5. I also commented  
out the js.Boot code in the main generate method, since I knew I wouldn't  
need that either.

This all took only a minute or so, and since macros are a built-in feature  
of haxe, I think it's fair game :)

The DefaultJSGenerator has everything there, so I was really just "weeding  
out" a few things I didn't want. All my code was still dynamically  
generated, based on what was written in my HelloWorld class, I just  
ignored the bootstrap code I didn't need.

This could be a great tool for places where size totally matters, or to  
clean up interactions with a toolset like Node.js or Titanium



On Fri, 14 Oct 2011 01:24:06 -0700, sledorze <[hidden email]>  
wrote:

> Does your macro prevent certain class of program from working that would  
> work
> with the normal Js generator?
>
>
>
> --
> View this message in context:  
> http://haxe.1354130.n2.nabble.com/5-lines-of-code-tp6891558p6891669.html
> Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

singmajesty
In reply to this post by Juraj Kirchheim
Thanks, that is a nice way to go :)

I went untyped because I knew it would create less lines of code. However,  
as a joke I almost considered commenting out the newlines and "taking the  
win" with 1 LOC

https://gist.github.com/1287438



On Fri, 14 Oct 2011 04:53:46 -0700, Juraj Kirchheim  
<[hidden email]> wrote:

> As a slight improvement:
>
> @:native('console') extern class Console {
> static public function log(s:String):Void;
> }
> class Main {
> static function main() {
> Console.log('hello world');
> }
> }
>
> On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
> <[hidden email]> wrote:
>> Everyone probably knows about the infamous "Hello World" sample for  
>> Google's
>> Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of
>> code (http://t.co/YFucTkBW).
>>
>> Following that fiasco, Justin Donaldson tweeted his "Hello World"  
>> sample for
>> haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>>
>> Earlier this evening a challenge came in by way of CoffeeScript,  
>> compiling a
>> "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>>
>> Well, I am happy to say that haxe was not one to be out-done. Winning  
>> the
>> "crown" for "Hello World" compiled code, here are haxe compiles for 7  
>> lines
>> of code (http://t.co/HTuqKnOl) and 5 lines of code  
>> (http://t.co/KiCMnfRq)
>>
>>
>> Of course this is all silly competition, but just in case you were  
>> wondering
>> whether haxe was cool enough or not ;)
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

Cauê W.
hahaha you cheater :P

Doesn't --dead-code-elimination work with the Reflect class also? This would be much less cheating, as the whole haxe api would be available, but you pay only for what you use

2011/10/14 Joshua Granick <[hidden email]>
Thanks, that is a nice way to go :)

I went untyped because I knew it would create less lines of code. However, as a joke I almost considered commenting out the newlines and "taking the win" with 1 LOC

https://gist.github.com/1287438




On Fri, 14 Oct 2011 04:53:46 -0700, Juraj Kirchheim <[hidden email]> wrote:

As a slight improvement:

@:native('console') extern class Console {
       static public function log(s:String):Void;
}
class Main {
       static function main() {
               Console.log('hello world');
       }      
}

On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
<[hidden email]> wrote:
Everyone probably knows about the infamous "Hello World" sample for Google's
Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of
code (http://t.co/YFucTkBW).

Following that fiasco, Justin Donaldson tweeted his "Hello World" sample for
haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).

Earlier this evening a challenge came in by way of CoffeeScript, compiling a
"Hello World" sample in 8 lines of code (http://t.co/3J1872qn).

Well, I am happy to say that haxe was not one to be out-done. Winning the
"crown" for "Hello World" compiled code, here are haxe compiles for 7 lines
of code (http://t.co/HTuqKnOl) and 5 lines of code (http://t.co/KiCMnfRq)


Of course this is all silly competition, but just in case you were wondering
whether haxe was cool enough or not ;)

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

Juraj Kirchheim
Well, actually one should be able to create a haXe dialect, where an
empty file compiles to a one-line "hello world" program :D

On Fri, Oct 14, 2011 at 6:05 PM, Cauê Waneck <[hidden email]> wrote:

> hahaha you cheater :P
> Doesn't --dead-code-elimination work with the Reflect class also? This would
> be much less cheating, as the whole haxe api would be available, but you pay
> only for what you use
>
> 2011/10/14 Joshua Granick <[hidden email]>
>>
>> Thanks, that is a nice way to go :)
>>
>> I went untyped because I knew it would create less lines of code. However,
>> as a joke I almost considered commenting out the newlines and "taking the
>> win" with 1 LOC
>>
>> https://gist.github.com/1287438
>>
>>
>>
>> On Fri, 14 Oct 2011 04:53:46 -0700, Juraj Kirchheim
>> <[hidden email]> wrote:
>>
>>> As a slight improvement:
>>>
>>> @:native('console') extern class Console {
>>>        static public function log(s:String):Void;
>>> }
>>> class Main {
>>>        static function main() {
>>>                Console.log('hello world');
>>>        }
>>> }
>>>
>>> On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
>>> <[hidden email]> wrote:
>>>>
>>>> Everyone probably knows about the infamous "Hello World" sample for
>>>> Google's
>>>> Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of
>>>> code (http://t.co/YFucTkBW).
>>>>
>>>> Following that fiasco, Justin Donaldson tweeted his "Hello World" sample
>>>> for
>>>> haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>>>>
>>>> Earlier this evening a challenge came in by way of CoffeeScript,
>>>> compiling a
>>>> "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>>>>
>>>> Well, I am happy to say that haxe was not one to be out-done. Winning
>>>> the
>>>> "crown" for "Hello World" compiled code, here are haxe compiles for 7
>>>> lines
>>>> of code (http://t.co/HTuqKnOl) and 5 lines of code
>>>> (http://t.co/KiCMnfRq)
>>>>
>>>>
>>>> Of course this is all silly competition, but just in case you were
>>>> wondering
>>>> whether haxe was cool enough or not ;)
>>>>
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

singmajesty
In reply to this post by Cauê W.
--dead-code-elimination still includes the standard bootstrapping code,  
about 300 lines.

Optimizing --dead-code-elimination might be the best way to implement a  
"minimal JS" target


On Fri, 14 Oct 2011 09:05:03 -0700, Cauê Waneck <[hidden email]> wrote:

> hahaha you cheater :P
>
> Doesn't --dead-code-elimination work with the Reflect class also? This  
> would
> be much less cheating, as the whole haxe api would be available, but you  
> pay
> only for what you use
>
> 2011/10/14 Joshua Granick <[hidden email]>
>
>> Thanks, that is a nice way to go :)
>>
>> I went untyped because I knew it would create less lines of code.  
>> However,
>> as a joke I almost considered commenting out the newlines and "taking  
>> the
>> win" with 1 LOC
>>
>> https://gist.github.com/**1287438 <https://gist.github.com/1287438>
>>
>>
>>
>>
>> On Fri, 14 Oct 2011 04:53:46 -0700, Juraj Kirchheim <
>> [hidden email]> wrote:
>>
>>  As a slight improvement:
>>>
>>> @:native('console') extern class Console {
>>>        static public function log(s:String):Void;
>>> }
>>> class Main {
>>>        static function main() {
>>>                Console.log('hello world');
>>>        }
>>> }
>>>
>>> On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
>>> <[hidden email]> wrote:
>>>
>>>> Everyone probably knows about the infamous "Hello World" sample for
>>>> Google's
>>>> Dart language, clocking in at a hefty (and astonishing!) 17,259 lines  
>>>> of
>>>> code (http://t.co/YFucTkBW).
>>>>
>>>> Following that fiasco, Justin Donaldson tweeted his "Hello World"  
>>>> sample
>>>> for
>>>> haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).
>>>>
>>>> Earlier this evening a challenge came in by way of CoffeeScript,
>>>> compiling a
>>>> "Hello World" sample in 8 lines of code (http://t.co/3J1872qn).
>>>>
>>>> Well, I am happy to say that haxe was not one to be out-done. Winning  
>>>> the
>>>> "crown" for "Hello World" compiled code, here are haxe compiles for 7
>>>> lines
>>>> of code (http://t.co/HTuqKnOl) and 5 lines of code  
>>>> (http://t.co/KiCMnfRq
>>>> )
>>>>
>>>>
>>>> Of course this is all silly competition, but just in case you were
>>>> wondering
>>>> whether haxe was cool enough or not ;)
>>>>
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>>>
>>>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: 5 lines of code

Cauê W.
it wouldn't be too hard to implement a way to impact less the bootstrapping code. Maybe if you don't use Arrays, for example, no need for arrays bootstrapping.

2011/10/14 Joshua Granick <[hidden email]>
--dead-code-elimination still includes the standard bootstrapping code, about 300 lines.

Optimizing --dead-code-elimination might be the best way to implement a "minimal JS" target



On Fri, 14 Oct 2011 09:05:03 -0700, Cauê Waneck <[hidden email]> wrote:

hahaha you cheater :P

Doesn't --dead-code-elimination work with the Reflect class also? This would
be much less cheating, as the whole haxe api would be available, but you pay
only for what you use

2011/10/14 Joshua Granick <[hidden email]>

Thanks, that is a nice way to go :)

I went untyped because I knew it would create less lines of code. However,
as a joke I almost considered commenting out the newlines and "taking the
win" with 1 LOC

https://gist.github.com/**1287438 <https://gist.github.com/1287438>





On Fri, 14 Oct 2011 04:53:46 -0700, Juraj Kirchheim <
[hidden email]> wrote:

 As a slight improvement:

@:native('console') extern class Console {
      static public function log(s:String):Void;
}
class Main {
      static function main() {
              Console.log('hello world');
      }
}

On Fri, Oct 14, 2011 at 9:40 AM, Joshua Granick
<[hidden email]> wrote:

Everyone probably knows about the infamous "Hello World" sample for
Google's
Dart language, clocking in at a hefty (and astonishing!) 17,259 lines of
code (http://t.co/YFucTkBW).

Following that fiasco, Justin Donaldson tweeted his "Hello World" sample
for
haxe, coming in at 296 lines of code (http://t.co/DiwQtcyA).

Earlier this evening a challenge came in by way of CoffeeScript,
compiling a
"Hello World" sample in 8 lines of code (http://t.co/3J1872qn).

Well, I am happy to say that haxe was not one to be out-done. Winning the
"crown" for "Hello World" compiled code, here are haxe compiles for 7
lines
of code (http://t.co/HTuqKnOl) and 5 lines of code (http://t.co/KiCMnfRq
)


Of course this is all silly competition, but just in case you were
wondering
whether haxe was cool enough or not ;)

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org