Live data from Hacker News

Java for Everything

teamten.com

141–150 of 344 posts

Re: Java for Everything

#141

You have to appreciate bombastic statements like this for forcing you to confront your assumptions. "Everything in Java? Even a kernel? That's absurd." you think, and then wonder what makes it absurd, and realize that it could perhaps be done with some modifications, and remember Singularity, etc. But on the other hand, this is well trod ground. Everything WAS going to be Java. Remember picoJava, the bytecode-native…

> So honest question: what's different this time?

We've rediscovered ahead-of-time compilation.

Re: Java for Everything

#142

Java is perfect also for client side. We have a client app (a complex VoIP softphone) with different codebase for all platforms (C++ for windows, java for android, ObjectC for iOS). Right now we are in the way to reduce all this in one single codebase written in Java and the user interface in html/css/javascript, so the user interface is always running in a webview. -Java for windows desktop (there are pretty install…

This is horrible, but not because of the Java part — it's the webview that puts your desire for a single UI technology stack ahead of user's desire for a decent UX.

Re: Java for Everything

#143
What he said, but C#.

C#'s one of the most versatile languages which can target most of the popular platforms, e.g: iOS/Android (Xamarin), WindowsPhone, Windows, Linux, OSX, Silverlight, PS4, XBox (announced), Unity3D and NaCL.

C#/.NET's biggest weakness of sub-optimal cross-platform support should also be resolved in the near future now that .NET's compiler, core runtime and class libraries are OSS and with Microsoft announcing support and plans to release official distributions for Linux and OSX - so .NET will finally have multi-platform support of a single code-base resolving earlier issues or running .NET on OSX/Linux due to different impls.

Re: Java for Everything

#144
post #62

Earlier quoted context omitted.

80% of the problems with java as it's usually written are bad policy rather than fundamental language problems. But there are real cases where language limitations mean you have to either use an unpleasant framework or write unpleasant code. Jersey's annotations are pretty nice, but they're still annotations, not really part of your code. You can be bitten by silly errors like an implementation's annotations not quit…

So here's the thing about annotation and Jersey, I believe you can annotate the seralization of return type once at the top of your resource class, the rest, like http verb, needs to be repeated unless you take the convention one more level up a'la Rails. But that's Rails, a web framework that people said does not fit for microservice. Sinatra is. But if you take a look at how Sinatra (or Rails) serialize the returne…

> But if you take a look at how Sinatra (or Rails) serialize the returned object, you notice the duplicated code. Especially if you want to return both JSON or XML based on the request header. To add to this, both frameworks do this serialization as part of the code logic that you have to write, instead of slapping annotation once...

I can't speak for Sinatra, but in Spray I'd just write a directive for this - maybe it exists already, but if not, it's a couple of lines - and then I can use it just like any of the built-in directives. And this is a perfect example of why "just code" is so powerful. Jersey is a very well-designed framework and I'm sure you can find examples where the built-in Jersey thing is better than the built-in Spray thing. But no framework is perfect, at some point you find yourself having to extend these things - and in Jersey's case, IIRC once you want to write your own annotation you need a magic .service file containing a class name to use to interpret that annotation. And then the only way to pass dependencies to that processor is by static global variables. Good luck refactoring that, and don't expect to be able to use hot code replace when debugging it. And good luck remembering how the mechanism works in six months' time. "Plain old code" has a lot to recommend it here.

> Let's take this further: exception mapping to http response code. In JAX RS, you can map application exception to certain WebApplicationException with specific http response code, I believe you have to handle them manually in Sinatra.

Again, trivial in Spray - I do my error-handling with Either and then I have a meta-marshaller that knows what to do with the error case. Better still, error handling isn't a special case - I do exactly the same thing if I have async code in my methods (can JAX-RS handle Futures? Can it handle a different kind of Future from a non-standard third-party library?). I can do exactly the same thing with a database-transaction monad, and then I can have session-in-view but in a principled, safe, zero-magic way. I can do the same thing to e.g. show debug traces if a special header is present - like Jersey's dynamic choice of serialization format that you were so impressed by, but it doesn't have to be built into the framework, it's just code that I can write myself.

Re: Java for Everything

#145
post #47

Earlier quoted context omitted.

DISCLAIMER: I write mostly java, at home and at work. Refactoring goes a lot further than just renaming types. A refactor script _WILL_ rename both sides of 'Foo x = new Foo();' to 'Bar x = new Bar();', so given the right utilities (and if you use java for everything, it's _MUCH_ easier to become an expert at the tools!) this is not any more effort at all. However, there are refactors for things that are much more di…

Refactoring goes a lot further than just renaming types. A refactor script _WILL_ rename both sides of 'Foo x = new Foo();' to 'Bar x = new Bar();', so given the right utilities (and if you use java for everything, it's _MUCH_ easier to become an expert at the tools!) this is not any more effort at all. Ctrl-Shift-R B A R No, not much effort at all. Just twice as many keystrokes. I wouldn't even mind the verbosity if…

I don't understand the point. Are you claiming that search and replace functionality provides the same ease of use as an actual rename refactor ?

  Foo x = new Foo();
  int Fool = 5;
I'm sure you see the problem.

Dynamic languages are great, until the program grows. Then you hate yourself for having picked a duck/dynamic typed language (including Go, btw : programs become unmaintanable if they grow, not as bad as python and the like, but ...).

Re: Java for Everything

#146

Earlier quoted context omitted.

I suspect readability isn't a big priority for you. Here's how I'd write this, lambdas or not: public static List sortDescending(List ints) { ints.sort(new Comparator () { @Override public int compare(Integer o1, Integer o2) { if (o1.equals(o2)) { return 0; } else if (o1 My personal perspective is that your use is a typical abuse which turns simple code into something unreadable and overly complex. This makes code ha…

shrug . This seems like a pretty standard use of the ternary operator to me. I mean, just google examples of Comparator, and you'll find tons of examples like this: @Override public int compareTo(Object arg0) { Country country=(Country) arg0; return (this.countryId country.countryId ) ? 1:0 ; } ( http://www.javacodegeeks.com/2013/03/difference-between-comp... ) But that's orthogonal to my point, which is that lambdas…

I'd have to agree, the GP is very bloated when a simple ternary will suffice.

Re: Java for Everything

#147

Earlier quoted context omitted.

Keep in mind that JAX-WS with JAX-B beats other rival libraries in other languages. If your requirement is to be a client that consumes SOAP web service given wsdl, I'd take Java any given day. The wsimport and wsdl tool that JDK provides beat any libraries. Also, JAX-B annotation can serialize and deserialize to JSON given the right provider. That's JSON, XML with POJO with the price of one. Good example of Java eco…

False. If you use a language that's homoiconic (any Lisp), you don't need to serialize anything. The source code of the language is already in its serialzed form. You can't beat the speed of not having to do something in the first place. As an aside, no sane person would write a SOAP webservice today.

This may be true but there are many existing SOAP webservices out there still, and the parent mentioned consuming a SOAP API.

Re: Java for Everything

#148
post #143

What he said, but C#. C#'s one of the most versatile languages which can target most of the popular platforms, e.g: iOS/Android (Xamarin), WindowsPhone, Windows, Linux, OSX, Silverlight, PS4, XBox (announced), Unity3D and NaCL. C#/.NET's biggest weakness of sub-optimal cross-platform support should also be resolved in the near future now that .NET's compiler, core runtime and class libraries are OSS and with Microsof…

My version would be "what he said, but choose any well-supported statically typed language, particularly one with decent type inference, since that gets you a lot of the convenience of dynamic typing without all of the very many runtime-error downsides".

Re: Java for Everything

#149
post #51

I like how the author made the point about the commenting. I never realised it until I started my work training at a big company. I'm reading my colleague's C# (ASP.NET MVC) code and find it requires no commenting to understand even though I started learning C# pretty much on the job. I then had to laugh when I needed to explain some JavaScript (and jQuery) I wrote to him and exclaimed, "What the hell is this doing!"…

> As for Java and C# on the web. I just wish it was more accessible to smaller companies. 100% of my freelance stuff are using cheap hosting that rarely support anything more than Perl/PHP.

One year ago I would have agreed with you, but I have since discovered some of the newer PaaS solutions like CloudFoundry / Pivotal CF [1] and OpenShift [2].

I'm using Pivotal CF for my current side project (a public website + web service) and am paying about $7/month.

[1] http://www.pivotal.io/platform-as-a-service/pivotal-cf

[2] https://www.openshift.com/

Re: Java for Everything

#150
post #81

A significant amount of the article is arguing that Java for everything is better because the author and his coworkers already knows it. I can make the same argument for Python _for me_. And for my company too; we have a ton of Python developers already, so it makes sense to write things in Python if possible in case someone needs to change or improve anything. The author also talks about how Java's verbosity is a tr…

> There are some valid points raised too, such as concerns about Python's scalability

But if you think about the two python scalability problems :

1) speed

2) programs become unmaintainable as they grow way quicker than they do in java and the like

Nobody's arguing to write shell-scripts in Java. Why are people arguing writing websites that will include more than a trivial amount of functionality in anything but Java ?

Post reply on HN