I linked to the anchor where it says that, right to the bottom of the section 4.3. Will people just STOP saying JavaScript was ‘never intended’ to have ‘nothing to do with Java’? They clearly meant JavaScript to be to Java what AWK is to C, at least syntax-wise. I was born one year after JS was conceived (the standard says ‘invented’, invented my ass! Who ‘invents’ a language?) so I am too young to have been around in the early days of web. But it seems like people back then wanted Java to be lingua franca of web, a bit like PostScript in the thread I posted a few hours ago. They named it JavaScript to assure people that it’s the interpreted, scripting form of Java.

Now don’t say ‘JS and Java are like car and carpet’ you will look like an idiot.

Also if you are wondering why I am reading the standard, it serves two purposes. First is, I wanna implement it one day in the future. Second is, I know shit about web scripting and I wanted to make myself a blog and I miserably failed. So I am learning it.

I know nobody asked, but one person might be wondering why someone would do this to himself.

JavaScript was created by Brendan Eich for the Netscape Browser. The job said to embed Java in the browser, but Eich was a Lisp guy and wished he could actually embed Scheme instead. Scheme is about as far as Java as one can get in terms of paradigm. Eich must have been stubborn because the result was JavaScript which is almost, but not quite, entirely unlike Java. Lulled by the seemingly familiar syntax, decades of coders have been baffled by the wild prototype-based object paradigm and the functional style hiding underneath.

JavaScript being somewhat like Java was an arbitrary constraint that was pushed by marketing and that was very partially honoured during implementation. The kinship between the two languages is slim at best. When explaining tech issues to the layperson, it’s important not to sweat the details and get to the point. Here the point is: JavaScript and Java are like car and carpet.

Also, chill. You have a lot to learn. We all do. Stop saying your colleagues look like idiots.

Good info dump. Can’t image S-Expressions in web dev today really. Also, I did not mean it maliciously, this is a stupid thing after all.

No biggie! The birth of JS is told in numerous different places (and ways) on the net, if you’re curious you should definitely look it up.

@Faresh@lemmy.ml
link
fedilink
English
18M

To be honest, XML can be considered to just be a more verbose version of s-expressions. It is easy to convert between XML and SXML.

Verbose and ugly! Btw, check out this S-Expression parser in C I wrote several months back: https://gist.github.com/Chubek/d2f0ac9067521716d2ab31c93948e885

It’s truly *easy to parse them!

Max-P
link
fedilink
38M

Oh they sure did. ES4 was going to very much be like Java, with static types and a fair bit of what TypeScript looks like today. We got very close to taking a completely different direction. It was ultimately doomed by IE among other things, which is ironic given Microsoft came up with TypeScript a decade later that does more or less the same thing as ES4 was meant to be. But it got scrapped and we got ES5 instead.

https://evertpot.com/ecmascript-4-the-missing-version/

I used to use IE when I was like 12~13 — I think I switched to FF when I was 13.5 and never looked back. Just the tabs man. I use Pop_OS! these days and a few months ago I accedentally enabled tiling, then it I realized it has tabs. I am as happy as I were back then. Tabs are a concept that were thought of too late.

btw this document mentions JScript. I don’t know WTF is that but when I google normal JS comes up.

@SuperIce@lemmy.world
link
fedilink
English
68M

If you actually knew how to program both Java and JavaScript (originally called Mocha btw), you would know that they are very different languages. Saying that JS was intended to have a similar syntax to Java is like saying Java was intended to have a similar syntax to C. They’re both true, but it doesn’t really mean anything.

Frankly one can learn any imperative language once one learns one. It’s the standard library of a language and the quirks of the library that is the real challenge .The syntx of the language doesn’t boggle anyone.

These two code blocks don’t use standard libraries (aside printing output) and have nothing in common. Even output is totally different, since at the time JavaScript did not support text output at all (there was no browser console). They are as close as you can possibly get between the two languages (they’re not really close at all, because in the 90’s it wasn’t possible to define “real” classes in JavaScript, and to this day it’s not possible for a function to have instance variables in Java).

And as someone who’s been writing JavaScript professionally for 20 years… I assure you it’s full of quirks that still confuse the heck out of me at times. I mean just last week I had a problem with variable scope that took me three hours to figure out what was wrong with the code. I’m sure some people are more familiar with it, but I’m not one of those people… probably because I avoid the language as much as I possibly can and try to make it behave like “any other language” even though it definitely isn’t that.

Java:

public class Animal {
    private String name;

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }
}

public class Application {
    public static void main(String[] args) {
        Animal myAnimal = new Animal("Spike");
        System.out.println(myAnimal.getName());
    }
}

JavaScript:

function Animal(name) {
    this.name = name;
}

Animal.prototype.getName = function() {
    return this.name;
};

var myAnimal = new Animal("Spike");
alert(myAnimal.getName());

I do believe other people have pointed out what went on that caused this to happen. This thread was a joke, but I did learn a lot from it.

etrotta
link
fedilink
English
98M

Would an experienced Java developer that has never touched JavaScript before know how to use JavaScript well enough to use it in a professional application without having to learn/revise a lot of things?

Would an experienced JavaScript developer that has never touched Java before know how to use Java well enough to use it in a professional application without having to learn/revise a lot of things?

No and No - They are like car and carpet. Unlike something like C and C++ or JavaScript and TypeScript that you can easily adapt to in a relatively small amount of time, Java and JavaScript serve completely different use cases and require significantly different skillsets.

Ugh I think the gap between c and c++ is wider than between java and Javascript, but admittedly I haven’t done much of the latter two

You can take the contents of a C file, put it into a C++ file and there’s an 80% chance it will work without modification, and 15% of the incompatibility will be just sticking a type on your pointer instead of using void pointers (untyped pointers), or in newer code switching the restrict keyword for one of C++'s newer pointers.

You can’t do that between JS and Java.

Douglas Crockford, author of “JavaScript: The Good Parts” has said:

“JavaScript is the only language in the world that people think they write without learning it first.”

I think this is a true statement (well, that and bash).

Java and JavaScript are like car and carpet because despite the beginning of the names matching they serve different purposes. In the early web days Java applets were a thing and it failed which is why a new language was needed. It’s not a secret that there was pressure to make Javascript look like Java, that’s just not the point of the figure of speech.

They clearly meant JavaScript to be to Java what AWK is to C

No. From interviews with the people who created JavaScript what actually happened is they invented an awesome new language, and the boss had just signed a contract to integrate Java into Netscape.

That contract specifically banned Netscape from supporting anything other than Java… but the new language was so awesome they didn’t want to kill it. The compromise was to call it “JavaScript” and insist it’s not a new language, it’s just a light weight version of Java. Even though clearly that was bullshit and they all knew it - they just didn’t admit it publicly until decades later.

This makes so much sense! The other guy said they were planning an S-Expression language like Scheme… I think, had Netscape supported Scheme, the trajectory of the craft would change. At least we would not get so many ‘durr parenthesis’ memes. Just how hard is it to use [Neo]Vim when you’re writing S-Expressions? it keeps highlighting the paranthesis and brackets balance as I write. What text editor do people who hate S-Expression LISP-like languages use, Emacs? Lol.

Emacs is written in lisp, so if people are going to die on the hill that they hate s expressions then I’m going to say no: they probably won’t be using emacs

macniel
link
fedilink
21
edit-2
8M

Who ‘invents’ a language?

Linguists or Developers.

They named it JavaScript to assure people that it’s the interpreted, scripting form of Java.

Who are they? There was that one guy who developed JavaScript, and he decided on the name of JavaScript, not ECMA.

Now don’t say ‘JS and Java are like car and carpet’ you will look like an idiot.

JS and Java are like car and carpet.

There was that one guy who developed JavaScript

Bullshit. AOL was a huge company with large development teams and lots of people worked on JavaScript. Obviously there was a project lead and in the beginning he did most of the work, but a project that big doesn’t get done by one person and by the end he would have been doing less than 1% of the work.

he decided on the name of JavaScript

The legal teams at AOL and Sun Microsystems negotiated JavaScript as part of a deal where AOL would “only” pay millions of dollars per month to license Java as long as they didn’t include any other programming languages in the browser. JavaScript wasn’t a separate language, we promise.

Superb
link
fedilink
English
6
edit-2
8M

No, JavaScript was originally slapped together in 2 weeks at the last minute by one dude. It doesn’t take a team to put together a small interpreter

@SuperIce@lemmy.world
link
fedilink
English
128M

It wasn’t even called JavaScript originally, it was called Mocha. It was then renamed to LiveScript before its original release. Then, Netscape wanted a licensing agreement with Sun to integrate Java into Navigator, and part of the agreement was to rename LiveScript to JavaScript with Sun holding the trademark for JavaScript. They also talked a lot about using JS to modify the properties and behaviors of Java applets in the 1995 press release, but that never really happened.

Yeah and java is the same as c lol

They have similarities in Syntax but that’s about it.

Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1 user / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog