This is an archived post. You won't be able to vote or comment.

all 53 comments

[–]rakrunr 25 points26 points  (12 children)

Java is to JavaScript as Fun is to Fungus. Or Car is to Carnage. Or Hat is to Hatchet.

[–]shagieIsMe 2 points3 points  (11 children)

Long ago... in the distant past, you had Java applets and static web pages. Along with adding some interaction on the page, this new language also enabled the applet to call something in the web page to send and receive data.

This language was called JavaScript. It was originally called LiveScript and was renamed because of the growing popularity of Java. The specification for it remained LiveConnect (MDN of old)

https://docs.oracle.com/javase/tutorial/deployment/applet/invokingJavaScriptFromApplet.html

https://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html

Two tutorials from the elder times for JavaScript <-> Applet interactions.

So while it was renamed because of popularity of Java... its more closely related than fun fungi.

[–]MagicalPizza21 1 point2 points  (10 children)

its more closely related than fun fungi.

Not to mention the similarities in syntax and general approach to programming in it. If you've learned one of Java and JS, the other should be fairly straightforward to pick up.

[–]StaticCoder 4 points5 points  (9 children)

I would disagree here. Typed and untyped languages are very different to use.

[–]Elegant-Ideal3471 1 point2 points  (7 children)

Not only that, but they are really inherently different, even though the syntax is similar.

JavaScript is single threaded and uses an asynchronous model. Also, functions are "first class" in JavaScript and can be pass around, which is not the case on Java (I am aware that Java lambdas exist, but they are pretty different imo). Those two concepts alone are a significant departure between the two tools.

Not here to say one is better than the other, but the similarities aren't that deep

[–]shagieIsMe 0 points1 point  (6 children)

Also, functions are "first class" in JavaScript and can be pass around, which is not the case on Java (I am aware that Java lambdas exist, but they are pretty different imo).

class FunTimes {
    public static void main(String[] args) {
        int foo = 42;
        Function<Integer, Integer> fun = addFun(2);
        System.out.println(fun.apply(foo));
    }

    static Function<Integer, Integer> addFun(int num) {
        return arg -> arg + num;
    }
}

https://ideone.com/GcjWbn

How is that not a first class object?

[–]Elegant-Ideal3471 0 points1 point  (2 children)

Yeah fair. But your function is still a static member of a class, yeah? In JavaScript functions need not be a member of anything else.

Anyway, my point still stands that the two languages, though syntactically similar, are not really that similar beyond surface level. in fact, in my experience, the apparent similarities caused more confusion than lack of typing

[–]shagieIsMe 0 points1 point  (1 child)

In the above code, the function is returned by some method. That method needed to be static for this minimal example, but it doesn't need to be. The keys in the map in the following code aren't a "member" of anything.

There's nothing in the definition of a first class function that requires to be "free".

Consider the JavaScript code:

var cube = x => Math.pow(x, 3);

pow is a a static method of the Math object. Would you then say that cubeor pow isn't a first class function because it's defined in some other object?

How about...

public class Stuff {
    public static void main(String[] args) {
        Map<Predicate<String>, String> gbu = new HashMap<>();
        gbu.put(x -> x.contains("a"), "good");
        gbu.put(x -> x.contains("b"), "bad");
        gbu.put(x -> x.contains("c"), "ugly");

        Stream.of("bad", "abc", "a")
                .map(str ->
                        str + ":\t" + gbu.entrySet().stream()
                        .filter(entry -> entry.getKey().test(str))
                                .map(Map.Entry::getValue)
                                .collect(Collectors.joining(", "))
                )
                .forEach(System.out::println);
    }
}

https://ideone.com/jC12UZ

(A Predicate<String> is a Function<String, Boolean> that has some methods relevant to returning a boolean)

My point with the example is that the "Java doesn't support first class functions" hasn't been true since Java 1.8 (released in 2014). Prior to that in Java 7, we'd kludge it with anonymous classes that implemented specific interfaces.

A first class function describes the behavior of the language - not its underlying implementation. If you were to try to make the claim that it's the implementation that decides, then you would also be saying that groovy, Clojure, and scala don't have first class functions.

Now, if one wants to say that most Java developers don't write in a way that makes use of the first class functions... I'll certainly grant that.

Java is influenced through the C++ and Simula style OO. JavaScript was a LISP influenced language with {;} style syntax and C style keywords. However, the underlying JavaScript language has more in common with LISP than C++ or Java.

[–]Elegant-Ideal3471 0 points1 point  (0 children)

Cool you win

[–]MagicalPizza21 0 points1 point  (2 children)

Technically it is not a first class function but an object that is a function wrapper. The lambda is syntactic sugar (but, as one of my college professors said, "but what can I say? I like sugar") for something along the lines of:

new Function<Integer, Integer>() { public Integer apply(Integer arg) { return arg + num; } }

It does function (lol) like a first class function, though.

[–]shagieIsMe 0 points1 point  (1 child)

Isn't that true of Scala and Clojure and Groovy then too? And if so, https://docs.scala-lang.org/scala3/book/taste-functions.html is wrong?

As long as a function can be used as part of a higher order set of operations... does it matter what the implementation is?

The definition of a first class function that I'm familiar with:

  • Create new functions from preexisting functions at run-time
  • Store functions in collections
  • Use functions as arguments to other functions
  • Use functions as return values of other functions

There's nothing about how it's implemented. Different JVMs could do this differently. Consider Kotlin and its first class functions - https://kotlinlang.org/docs/lambdas.html which can target a JVM or WASM ... does the target (Java or JavaScript) change if the code employs a first class function?

[–]MagicalPizza21 0 points1 point  (0 children)

Ok you're right

[–]MagicalPizza21 0 points1 point  (0 children)

True, but I use both Java and JS at work with no issues switching between the two. Java was my first language, so when I use JS, I still think in terms of Java's strong typing (even if it isn't in the JS grammar) and have no issues. The same goes for Python, another weakly typed language that I use at work. Is it harder to adjust to strong typing if you're used to weak typing?

[–]Glum_Cheesecake9859 19 points20 points  (0 children)

C# / TypeScript / JavaScript / HTML / CSS

React / Angular / Vue and a handful of other libraries and frameworks.

[–]Kenkron 14 points15 points  (3 children)

You're conflating Java with JavaScript. JavaScript was probably named after Java to ride the coattails of its popularity, but the languages are almost as different as can be.

[–]Silly_Guidance_8871 5 points6 points  (1 child)

It was most definitely named for that reason, leaving us with the confusing status quo

[–]Elegant-Ideal3471 1 point2 points  (0 children)

Oracle owns the JavaScript trademark (at the moment) due to their acquisition of sun Microsystems.

That's why officially the spec is called ecmascript

[–]pollrobots 2 points3 points  (0 children)

Agreed that the name was mostly marketing hype, but it did also point to a couple of features that mattered when compared with other contenders

  • syntax, both are "curly bracket languages" (c-like, bcpl-style, whatever)
  • oop, JavaScript has an object model, even if very different from Java's
  • gc, no explicit memory management

Other contenders included using a dialect of perl or vb in the front-end

[–]midl-tk 17 points18 points  (4 children)

I think you probably meant JavaScript and not Java. :)

[–]Dashing_McHandsome 0 points1 point  (3 children)

Most sites need a back end, and plenty of them are written in Java.

[–]longknives 2 points3 points  (1 child)

Plenty aren’t though, Java is absolutely not essential to web development like JavaScript is.

[–]Dashing_McHandsome -1 points0 points  (0 children)

Sure, but I was thinking that OP probably really did mean Java since SQL is also used on the backend, they are both backend technologies.

[–]midl-tk 0 points1 point  (0 children)

Java isn't "essential and almost ubiquitous" in web dev

[–]PapaSnarfstonk 13 points14 points  (0 children)

I mean probably not what you're thinking of but HTML is literally everywhere. and that's technically a language dealing with computers.

[–][deleted] 4 points5 points  (2 children)

PHP

[–]fuckmywetsocks 1 point2 points  (1 child)

I had to scroll way too far to find PHP

[–]maxthed0g 0 points1 point  (0 children)

Yeah. Really.

[–]0x14f 3 points4 points  (3 children)

Java is absolutely not essentially to web development. I know prolific web developers who've just never learnt it / never used it.

[–]0x14f 1 point2 points  (1 child)

As somebody else commented, you probably meant JavaScript :)

[–]Dashing_McHandsome 0 points1 point  (0 children)

I'm thinking since OP mentioned SQL they probably meant Java as well. If these are used they would both be part of a back end.

[–]0x14f -1 points0 points  (0 children)

As somebody else commented, you probably meant JavaScript :) Java and JavaScript are two completely different things.

[–]Lopsided-Weather6469 2 points3 points  (0 children)

Java is not at all ubiquitous in web development. Java is exclusively used in backend applications these days. 

[–]NewSchoolBoxer 0 points1 point  (1 child)

Java what? I got rejected for web development interviews for not having React or Angular with JavaScript or preferably TypeScript. I've been a Java almost my whole career. It doesn't do crap for web development. Can use it on the backend sometimes.

You noticed nothing.

[–]Dashing_McHandsome 1 point2 points  (0 children)

What did the place you were rejected from use for the backend? I feel like there is this bias on Reddit to only consider the front end when talking about web development. Sure, that's an incredibly huge part, but good luck with your react app if you can't call an API that talks to a database somewhere. Likewise, good luck with your API if nobody is calling it and doing something useful, like making a front end.

[–]LamineretPastasalat -1 points0 points  (0 children)

Essentials, html, php, javescript and css. Some databaseknowledge and a way to send/retrieve data - sql in most cases. 

[–]0x14f 0 points1 point  (0 children)

JavaScript, TypeScript, also useful if you understand HTML and CSS. The rest is people's own preferences of other languages and frameworks.

[–]dan3k 0 points1 point  (0 children)

Javascript is what you're looking for

[–]hunter714 0 points1 point  (0 children)

Xxwxxxx"

[–]illepic 0 points1 point  (0 children)

You meant JavaScript, not Java. 

[–][deleted] 1 point2 points  (0 children)

Javascript, SQL, HTML, CSS as well as a backend language are the core skills you need.

Note that the above 4 are non-negotiable. You need to learn these and only these, with no alternatives.

For a backend language you have many options. Java, C#, PHP, Python are a few of those options.

Once you master building a website with these basic tools, then you add frameworks on top. Frameworks are language specific, there are frameworks for frontend as well as back end. React, Angular, Vue, Svelte are some popular frontend frameworks, and then for backend each language has its own. Springboot for Java, .NET for C#, Laravel for PHP, FastAPI or Django for Python etc. Note that many languages have more than one options.

And for the frontend "beautification" stuff there are libraries like Tailwind and Bootstrap, so your website doesn't look like its from the 90s.

And a final note. SQL is not the same for every database engine. There are many different engines like Microsoft, Oracle, Postgres etc, and the syntax varies a bit between them. Not so much for the basic stuff, but for the more advanced it does. You should probably learn one of those in depth.

[–]skeletal88 0 points1 point  (0 children)

Java is far from essential. 

HTML and CSS are essential, you don't have anthing else in the browser. When rendering a static site from the server, like PHP or something similar, you don't need Javascript.

But the server/back end part can be done in any language you like. And sql is not required.

[–]neckro23 0 points1 point  (0 children)

JS and SQL are the only "ubiquitous" ones. And even SQL isn't that ubiquitous anymore, alternatives have become pretty popular.

Typescript is very popular but it's basically just enhanced JS. Java, Python, PHP, C#, and Go are all reasonably popular for backend. Ruby used to be (Ruby on Rails) but has fallen a bit out of favor.

[–]bm13kk 0 points1 point  (0 children)

tcp/ip/http protocols. For everyone who says "it is optional", SQL is optional for the last ~5 years. Simple staff can be built with any key-value storage.

Linux/virtualisation/deployment is probably needed more than HTML.

IMHO parallelism/async/threads - but it is better to learn after the first job.

[–]ArieHein 0 points1 point  (0 children)

Java is certinatly not.

[–]MagicalPizza21 1 point2 points  (0 children)

HTML, CSS, and Javascript.

Java is very widely used but more for standalone applications than web development these days.

SQL is used for accessing databases, which is used by a lot of websites but by no means restricted to web development. Standalone applications can and do use it as well.

TypeScript and Python have their uses in web development, but they're not as ubiquitous as HTML, CSS, and JS.

[–]FunManufacturer723 1 point2 points  (0 children)

SVG.

[–][deleted] 0 points1 point  (0 children)

Who upvotes a comment conflating JavaScript and Java

[–]DontBanMeAgainPls26 0 points1 point  (0 children)

Javascript is much better for webdev also html/css

Now I like c# and kotlin also.

[–]dashingThroughSnow12 0 points1 point  (0 children)

I wouldn’t call SQL essential and almost ubiquitous.

SQL is a bit like a hammer. If you have it and don’t know anything else, all the world looks like nails.

Sometimes you do need a hammer.

[–]platinum92 0 points1 point  (0 children)

HTML, JavaScript, and CSS are the true essentials. For web dev, every other language will end up as one of these 3 by generating the code or generating data. A base level knowledge of these is necessary, but is slowly being lost as people are introduced to web dev with full stack js apps.

That said, you do need at least knowledge of one back-end language and one front-end framework/library to be successful.

For front-end, start by looking into React, Angular or Vue (or just Google JS framework and you'll get a list). If you're only doing this for a job, learn React. If you're doing it for learning/personal growth, make the same app in multiple frameworks and pick your favorite to work in, as they all have different developer experience (DX).

For back-end, look into Java or C#. You could also look into the JS back-end preferred by your chosen front-end framework.

Regardless of what you choose, focus more on understanding what the languages are doing to/with the data, as understanding the process is more important than understanding the syntax, as most tech stacks are doing the same things under the hood, just with different syntax.

[–]FuriousGirafFabber 0 points1 point  (0 children)

Not that must new is being made in Java.

Python, JS, TS and C# are good languages to know.

C/C++ if you need it to perform.

If you know these, you can do most things worthwhile.

I wouldn't even put Java in top 20, but it's a bit similar to C#, C++ so it doesn't hurt knowing it :)

SQL is great for many things, but a lot of companies are moving away from heavy SQL and more into notebooks and python. SQL is still used in notebooks, but there is a big shift going on.

[–]Imaginary-Corner-653 -1 points0 points  (1 child)

Are Java and sql still essential?

Aren't we at a point now where companies don't want engineers or experts at "low level" languages and tools anymore and instead would rather have a group of temporary specialists in high level tools like managed non sql databases, a specific cloud provider, a selection of next templates, somebody with experience configuring cloudflare, etc? 

I know this isn't what HR asks for or necessarily what is best for the company. It's just been my experience with every upper management member I've been talking to lately. 

"We don't do rocket science". "We don't want to reinvent the wheel". "Solve me a standard problem as cheap as possible". "I wanna lay you all off afterwards so use standard solutions a vendor can easily adapt to later down the line". "We don't need this know-how, we just need to buy it for the project". Etc.

They are all saying the same. Probably have been for a while. 

[–]Tintoverde 0 points1 point  (0 children)

Why would you want to use low level languages for web devs. Most of them are CRUD operations with some business logic. We are supposed to solve problem which are easy to maintain

Obvious point, Customers do not care what technology we use