Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

First Scripting Language for Web

Name: Anonymous 2013-09-08 22:37

I want to get off my mind of C and ((Scheme)) for a while and learn a scripting language for the web. My professor asked me if I could do a Javascript job for him and I said, I'd have to learn it first.

I want to learn Javascript or CoffeeScript but since the latter is simply a transcompiler for the other, should I learn Javascript first before getting to Coffeescript? I heard Coffeescript often makes more optimized code than Javascript, what if I just learn Coffeescript and submit the transcompiled code to my professor?

Name: Anonymous 2013-09-08 22:43

Just learn Javascript. It's not hard. Baby's first closures and all that.

Name: Anonymous 2013-09-08 22:43

>>1
How handsomely is your prof. going to pay for the job of prostituting your mind?

Name: biwascheme.github.io 2013-09-08 22:54

Name: Anonymous 2013-09-08 23:13

>>3
Around $400 every 15th day of the contract for 4 months. It's just a small task that can be done for 1-2 hours daily.

Name: Anonymous 2013-09-08 23:19

$3,200 eh? not worth it. Isn't that how much he gets paid in 2 weeks? 14.61. Meh, close enough.

Name: Anonymous 2013-09-09 0:19

Why the fuck are you trying to do that? That's like saying "oh guys i've been eating too healthy and now I want to start eating dog shit. Suggestions? What breed should I pick?"

Are you American?

Name: Anonymous 2013-09-09 0:20

>>5
its okay, do it, what kind of task is it?

Name: http://is.gd/F2RHP4 2013-09-09 1:24

>>1,5
Use Spock. Thread over.

This thread is closed. You can't reply anymore.

Name: Anonymous 2013-09-09 16:10

>>1
CoffeeScript is for people whose first language was Ruby.

# CoffeeScript - Assignment
number = 42
opposite = true

# JavaScript
var cubes, list, math, num, number, opposite, race, square,
__slice = [].slice;

number = 42;

opposite = true;

# CoffeeScript - Conditions
number = -42 if opposite

# JavaScript
if (opposite) {
number = -42;
}

# CoffeeScript - Functions
square = (x) -> x * x

# JavaScript
square = function(x) {
return x * x;
};

# CoffeeScript - Objects
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x

# JavaScript
math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};

# CoffeeScript - Splats
race = (winner, runners...) ->
print winner, runners

# JavaScript
race = function() {
var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners);
};

# CoffeeScript - Existence
alert "I knew it!" if elvis?

# JavaScript
if (typeof elvis !== "undefined" && elvis !== null) {
alert("I knew it!");
}

# CoffeeScript - Array comprehensions
cubes = (math.cube num for num in list)

# JavaScript
cubes = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i];
_results.push(math.cube(num));
}
return _results;
})();

Name: Anonymous 2013-09-10 1:19

>>1
The transcompiled code doesn't look anywhere as nice as CoffeeScript, but I wouldn't worry if the professor doesn't have a reputation for actually reviewing your code.

Both are shit, though.

Name: Anonymous 2013-09-10 5:13

>>11
youre mom is a shit

i fucked her last night

Name: Anonymous 2013-09-10 7:15

>>11

The transcompiled code is said to be more optimized though. Is this true or just bullshit?

Name: Anonymous 2013-09-10 7:17

>>13
Javascript a shit, so I wouldn't be surprised.

Name: Anonymous 2013-09-10 7:41

>>13
CoffeeScript
fib = (n) ->
(fib_r = (a, b, n) ->
if n <= 0
a
else
fib_r b, a + b, n - 1
) 0, 1, n

console.log fib 14


JavaScript
// Generated by CoffeeScript 1.4.0
(function() {
var fib;

fib = function(n) {
var fib_r;
return (fib_r = function(a, b, n) {
if (n <= 0) {
return a;
} else {
return fib_r(b, a + b, n - 1);
}
})(0, 1, n);
};

console.log(fib(14));

}).call(this);

Name: Anonymous 2013-09-10 9:49

>>10
})();
VALID JAVASHIT CODE

Name: Anonymous 2013-09-10 10:00

>>16

What's so bad about })();

Name: Anonymous 2013-09-10 10:19

>>17
What's so good about it? I understand what it does, but there's absolutely no reason for nigger-tacking your functions like that.

Name: Anonymous 2013-09-10 11:00

>>15
Scheme:
(define (fib n)
(do ( (a 0 b) (b 1 (+ a b)) (n n (- n 1)) )
((<= n 0) a)))

Name: Anonymous 2013-09-14 20:32

Hi, Hacker News.

Name: Anonymous 2013-09-14 20:51

>>20
r we being h4ck3d? D:

Name: Anonymous 2013-09-21 9:25

>>2

What book should I read to learn JS the right way?

Name: Anonymous 2013-09-21 10:44

>>22

w3schools.com

Name: Anonymous 2013-09-21 12:24

Name: Anonymous 2013-09-21 13:14

Name: Anonymous 2013-09-21 13:49

>>25
with all the advertising, the use of Microsoft ASP, and the tight layout, it just feels “icky”
For fuck's sake, web devs, get your shit together.

Name: Anonymous 2013-09-21 18:05

>>24,25
Can you give me a better explanation of why w3schools is evil/wrong/shouldn't exist/etc. than those links do? So far, the reasons I've seen are:

- ``Their name implies a false association with W3C that doesn't exist.'' (This is a good reason)
- ``Their information is wrong.'' I haven't actually seen any examples of this, it's just restated as a thing everyone knows.
- ``Their information is old.'' I don't get this. Are they advocating deprecated tags and falsely labelling them as part of a later version? The thing with a multi-versioned standard like HTML is that the older stuff is generally better supported, so as a beginner I'd prefer learning old, supported stuff over new, possibly-unstable stuff.
- ``They don't give much focus to HTML5.'' I don't see what's wrong with this, why would you give beginners lessons in something that is in constant flux?

Name: Anonymous 2013-09-21 18:32

>>27
The ``wrong'' information they give seems mostly to relate to PHP and MySQL, where you find atrocities like these in the first page where they cover insert statements:

<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";

mysqli_close($con);
?>


Terrible! Something which is, of course, to be expected from anything related to PHP, but this one is specially bad.

Source: http://www.w3schools.com/php/php_mysql_insert.asp

Name: Anonymous 2013-09-21 18:38

>>28
Oh, I see. That does seem rather unacceptable. Thanks for the example.

Name: Anonymous 2013-09-21 18:41

The web is shit anyway.

Name: Anonymous 2013-09-21 23:17

>>28
DB::table('Persons')->insert([
'FirstName' => Input::get('firstname'),
'LastName' => Input::get('lastname'),
'Age' => Input::get('age')
]);

Name: Anonymous 2013-09-22 1:50

]);
That was Javashit quality!

Name: Anonymous 2013-09-22 2:12

>>31
get($index = null, $default = null)
The get method allows you to read $_GET variables. Call without params to fetch the full array.

Why does that function do two entirely different things? And why are you performing inserts in a GET operation?

PHP QUALITY API DESIGN.

But yes, prepared statements are the way to go in any language. If you need to omit them for pedagogical reasons to make the use of SQL more clear, as I'm assuming that the people at W3Schools did, then you should just cover SQL, period.

Name: Anonymous 2013-09-22 11:02

>>33
It is Laravel, not FuelPHP.

Name: Anonymous 2013-10-30 11:33

Should I learn JavaScript first or CoffeeScript?

Name: Anonymous 2013-10-30 12:05

>>35
Should you eat a bucket of horse shit or dog shit?

Name: Prolog 2013-10-30 12:17

>>36
Yes.

Name: Anonymous 2013-11-04 1:25

>>1 you have many options if you want to avoid JS:

Emscripten: An LLVM-to-JavaScript Compiler
(obviously is not intended to use with the DOM, but it's useful if you want to avoid Flash or Java applets)
https://github.com/kripken/emscripten/wiki

LiveScript is a language which compiles to JavaScript.
If you are thinking to learn CoffeeScript you should first check this one.
http://livescript.net/

Wisp is homoiconic JS dialect with a clojure syntax, s-expressions and macros.
http://jeditoolkit.com/try-wisp/

Sibilant is a lisp-family language that compiles to readable and idiomatic JavaScript.
http://sibilantjs.info/

LispyScript - A javascript With Lispy Syntax And Macros
(the ``best'' of both worlds?)
http://lispyscript.com/

btw, javascript engines are superfast now (check V8), plus asm.js (http://asmjs.org/) will allow near native performance inside your browser.

Name: scheme in a browser 2013-11-04 3:20

>>38
if you want to avoid JS:
[aa]*Offers only Javascript recompilers[/aa]
if you want to avoid Flash or Java applets)
*Because Javascripts is 10x better than ActionScript bytecode Objects compiled in ClusterFF, and Java latte.
[aa]*Because Managers at Netscape were not to blame for disallowing Scheme as the de facto DOM scripting engine.

Name: Anonymous 2013-11-04 3:24

>>38
asm.js (http://asmjs.org/) will allow near native performance inside your browser.
and a cool free gaping prolapsing security anus

turboboosting a turd doesn't make it any less of a turd

Name: Anonymous 2013-11-04 6:04

Javascript (client-side website scripting) should have been a very simple and very restricted bytecode specification with an equally simple yet clever and powerful interface to the document tree.

Name: Anonymous 2013-11-04 13:40

Dogescript much scripty. Wow so geeky.

http://zachbruggeman.me/dogescript/

Name: Anonymous 2013-11-04 13:50

>>42
This made me very angry.

Name: Anonymous 2013-11-04 20:14

>>43
Ever seen LOLCODE?

Name: Anonymous 2013-11-04 21:56

>>44
I have, and I found it rather cute in a retarded way.

Name: Anonymous 2013-11-04 22:31

>>45
Maybe you meant "retarded in a cute way"?

Name: Anonymous 2013-11-04 23:05

>>45
But Dogescript is better than LOLCrap

Name: Anonymous 2013-11-05 1:27

>>47
You're like those retards who insist Javascript is better than PHP for web development.

Because drowning in a lake of piss is way better than doing so in a lake of vomit, right?

Don't change these.
Name: Email:
Entire Thread Thread List