Generate .js or .html by default?

52 views
Skip to first unread message

Alon Zakai

unread,
Sep 18, 2012, 8:36:29 PM9/18/12
to emscripte...@googlegroups.com
emcc (and our scons support and so forth) generate .js files
containing javascript by default, and not .html files containing HTML.
Generating HTML requires adding |-o X.html| and so forth to emcc. But
perhaps we should change this, LCID_Fire suggested it in a pull
request to change it for scons.

Originally emscripten only generated .js files, and we tested in the
shell and so forth. Later we added .html generation as an option, so
maybe this is just due to the history of the project that .js is the
default.

The question is what would most people find convenient - should .js or
.html be the default? If .html, we should definitely change it.

- azakai

Ehsan Akhgari

unread,
Sep 18, 2012, 9:57:56 PM9/18/12
to emscripte...@googlegroups.com
What is the rationale for generating HTML by default?  I think most real-world consumers would like to link to the generated code through a script tag anyway, so generating HTML by default may not be very helpful.

Cheers,
--
Ehsan
<http://ehsanakhgari.org/>

Alon Zakai

unread,
Sep 20, 2012, 2:08:52 PM9/20/12
to emscripte...@googlegroups.com
Yeah, if that's the case, then it would be a bad idea.

I wonder though if most new users don't just want to compile some code
and see results immediately. Simpler to see results in a browser than
the shell.

But I guess without clear reasons for changing this, we shouldn't.

- azakai

Ivan Vučica

unread,
Sep 20, 2012, 2:51:12 PM9/20/12
to emscripte...@googlegroups.com
Javascript definitely.

HTML is imho just a "wrapper", a "container" for the actual code in Javascript files. Most probably the HTML generated by emcc would not end up being used in production, anyway.

Ehsan Akhgari

unread,
Sep 20, 2012, 2:54:48 PM9/20/12
to emscripte...@googlegroups.com
Why not generate them both by default?  :-)  The HTML page can just link to the script file.

--
Ehsan
<http://ehsanakhgari.org/>

Alon Zakai

unread,
Sep 20, 2012, 6:52:51 PM9/20/12
to emscripte...@googlegroups.com
Yeah, good point, the html we create is nice for quick tests but
likely not what people use in serious projects...

I guess we should indeed leave it as js.

- azakai

LCID Fire

unread,
Sep 21, 2012, 11:02:03 AM9/21/12
to emscripte...@googlegroups.com
I am for changing the default for SCons only and here is why:
The change that I requested to pull is changing the PROGRAM extension. Say you want to compile Quake 1 with Emscripten then your end result is a program. And you very probably want to run it by itself.
The LIBRARY extension will still be js. So for zlib you would produce a static/shared library and then of course get a js.

Basically this is more of a bugfix because generating js for a program is surely not what people want.
I hope the issue is now clearer.

Alon Zakai

unread,
Sep 21, 2012, 1:41:05 PM9/21/12
to emscripte...@googlegroups.com
Hmm yeah, that does make sense. A downside though is that the output
is no longer a simple single html file which i think is nice for small
programs... so would be good to have two options. But that is starting
to sound complicated. I guess we should just leave it as is.

- azakai

Alon Zakai

unread,
Sep 21, 2012, 1:45:49 PM9/21/12
to emscripte...@googlegroups.com
But a 'program' could also be something you run in the shell or
node.js or such, I think? Commandline programs also run by themselves,
they aren't libraries.

Also, it seems like to be consistent here, we would need to compile .a
and .so files into .js, but .bc into .html (since the former are
libraries, and the latter is not). But I do see your point that scons
is a little different, if it says 'program' - .bc files do not say
program or library, even if they do not say library.

- azakai

LCID Fire

unread,
Sep 21, 2012, 3:07:21 PM9/21/12
to emscripte...@googlegroups.com
Well you are right, that theoretically a program might be headless. Although, personally I think that will be the exception to the rule. And mostly to a program x, there is a corresponding library libx, which should be used anyhow since parameters are easier set via code than commandline.
And PROGRAM and LIBRARY are indeed concepts in SCons which much more meta-meaning than what e.g. emcc handles.
That is the reason why I think we should change it for SCons only, since we have sufficient information to make the right choice.

Alon Zakai

unread,
Sep 21, 2012, 8:04:31 PM9/21/12
to emscripte...@googlegroups.com
Yeah, good points. I am convinced.

- azakai
Reply all
Reply to author
Forward
0 new messages