7 ms·
The JVM situation
- guard-of-terra 13y agoThe JVM is extremelly useful after you consider that all other foundations for higher gen languages are either: - Can't get threads really right. - Have some lousy pausing single-thread mark-and-sweep GC. - Is proprietary and bound to one dying platform. - (Bonus points) has 3rd party libraries that are not thread-safe or segfault from time to time. WRT "making language not unlike Scala but with better interop", Kotlin and some other projects seem to do that but they can't get themself out of the door :(
- praseodym 13y agoPeople should be investing time in Scala (compiler and tooling, e.g. IDE support) instead of designing their own language that probably won't get a lot of traction.
- guard-of-terra 13y agoI'm not sold on Scala and my colleagues aren't either. For an outsider it looks like a C++ for JVM: A language of endless short-sighted features that's going to bury yourself under it. It's not even Haskell because Haskell strives to be elegant.
- copx 13y agoActually C++ looks simple compared to Scala. E.g. C++ iterators seem complex and tricky compared to say Lua's. But let's just look at one element of Scala's truly byzantine iteration logic collection: Iterable Inherited: Iterable IterableLike Equals GenIterable GenIterableLike Traversable GenTraversable GenericTraversableTemplate TraversableLike GenTraversableLike Parallelizable TraversableOnce GenTraversableOnce FilterMonadic HasNewBuilder AnyRef Any Implicitly: by traversable2opsby MonadOpsby any2stringaddby any2stringfmtby any2ArrowAssocby any2Ensuringby alternateImplicit Source: http://www.scala-lang.org/api/current/index.html#scala.collection.Iterable http://www.scala-lang.org/api/current/index.html#scala.colle... ..and now explain what all these aspects actually do! And that's just one small element! And look at the method set of that thing.. Whoa! Again C++ suddenly seems minimalist.
- michaelochurch 13y agoScala is one of the best languages out there if your job is to write code. If you spend a non-trivial amount of time reading it, it depends on which of the sublanguages the original writers used. If Scala is used as "ML with OO features when really needed but not otherwise" it's quite nice, but I would not advise using Scala without a style guide for a multi-developer project.
- happy_dino 13y agoWhat happens is that every single bit of functionality is split up and abstracted away, so that code duplication is kept at a minimum. Considering that Scala ships with BOTH tons of collection types AND tons of useful operations, this seems to be a sane thing to do. Scala manages ... - to make both adding a new operation AND adding a new type not suck too much - to retain the “best” collection type through operations, without duplicating code left and right Most other languages fail already at point number one. No other language has managed to achieve point number two, let alone both.
- quatrevingts 13y agoTo be fair, this is a list of everything inherited, not just one level up, but the full transitive closure. All of the Gen* classes arrived with 2.9 when parallel collections were added. Also, the implicits shown are any implicits which can be invoked on Iterable, which includes all implicits which can be invoked on Any.
- jongraehl 13y agoAm I supposed to be intimidated by a list of 100 things you can do with an Iterable? Each one seems pretty reasonable. The C++ stdlib has 100 things you can do with iterators, too.
- praseodym 13y agoTo be honest, neither am I. I've done small projects in Scala (+libraries) and the amount of clever small features makes for short (maybe sometimes even elegant) code, but readability is a nightmare. Front and foremost, though, I found tooling to be lacking. Reading a stack trace is horrible, the compiler is slow and the two most mature IDEs (IntelliJ IDEA and Eclipse) both have problems highlighting/checking and completing code. For now, I'll probably stick with plain old Java.
- michaelochurch 13y agoFor now, I'll probably stick with plain old Java. You should consider Clojure. The community is evolving in a way that compensates for some of the tool chain problems, and Leinengen is definitely more intuitive than SBT. My traditional bias favors static typing, but I think Clojure might beat Scala because for most web applications, runtime typing (you can implement similar guarantees as in compiled languages; however, checking isn't at compile-time and therefore your testing will be less performant) is good enough.
- seanmcdirmid 13y agoBeen there and done that. However, designing languages to push the state of affairs forward is more my cup of tea (working on Scala helped with a lot of ideas though). Writing tooling is incredibly difficult, especially when Eclipse isn't really designed to support new JVM languages. It is easier to write an IDE for your language than to plug into Eclipes.
- profquail 13y agoI wouldn't say all other foundations for higher-order languages -- F# runs fantastically on the CLR (or Mono) and doesn't have any of those problems you listed.
- cgag 13y agoF# and the CLR aren't proprietary?
- seanmcdirmid 13y agoMono isn't proprietary.
- spartango 13y agoIn my experience Mono is a bit like the OpenJDK was a few years ago: Most things work, but there are a few things that are broken in unavoidable ways. Similarly, the performance isn't terrible, but the optimization is not quite at the same place as the original platform. Xamarin's rapid work suggests that there will be a 'production-ready' CLR for most platforms (they've got it down for iOS, Android, and recently OSX) soon enough.
- MetaCosm 13y agoI feel like Xamarin is in the uncanny valley of language / tooling features. Close enough to working to make the brokenness feel so much worse. If it was more raw, less IDE friendly (ala Go) that would be fine... or was more polished and had a better Xamarin IDE and plugin system, that would be fine as well. Right now, they are stuck in the odd middle, but it is still an amazing value if you are building common code cross platform apps.
- Fice 13y agoYes, but it can be a patent trap: https://www.fsf.org/news/2009-07-mscp-mono https://www.fsf.org/news/2009-07-mscp-mono, https://en.wikipedia.org/wiki/Mono_%28software%29#Mono_and_Microsoft.27s_patents https://en.wikipedia.org/wiki/Mono_%28software%29#Mono_and_M...
- pshc 13y agoRust is the anti-JVM. - Proper task isolation with pointer ownership. - No global GC. Task-local GC when needed, and explicit ownership otherwise. - Mozilla. - No NullPointerExceptions. Unsafe code is convenient when you need it.
- jacques_chester 13y agoI personally am really excited by Rust, but it's also still a fairly fast-moving target. Lots of work is still being done on the semantics of the language. It's an industrial research project, basically. When the semantics stabilise I reckon it'll be a technical winner in its chosen domain.
- jmgrosen 13y agoYes, certainly -- it's annoying to be working on some code, then update to a day-newer compiler and suddenly have a screen full of errors (as is currently the case). But in the long run, it'll be worth it, and I have no doubt that Rust will become an amazing language worth using.
- azth 13y agoAnd now you can browse Wikipedia in Servo (which is written in Rust): https://twitter.com/metajack/status/346822553089761281/photo/1 https://twitter.com/metajack/status/346822553089761281/photo...
- jacques_chester 13y agoServo is a good idea because it helps show the pain points of Rust on a real world project. But it doesn't show that Rust is ready for general use yet because that's really what it is -- another facet of the Rust project.
- azth 13y agoTrue. It is nice; however, to see a big project being developed side-by-side with the language.
- adamnemecek 13y ago"Scala is not a well-designed language" regardless of anyone's opinion, that's a pretty ballsy thing to say on the scala DL :-).
- octo_t 13y agoI think its recognised, even by people like Odersky, that the language has been significantly compromised by the decision to run on the JVM. It is an incredibly well-designed language, but lots of that effort has gone into covering up some really nasty warts.
- Aqueous 13y agoHere i am thinking it's the best language I've ever written in :-) I guess that's not really incompatible with still being "not a well designed language." When we're comparing ourselves to platonic ideals I guess the real thing can only pale in comparison. I just don't perceive the compromises. For me, attaining a factor of 5 lines to 1 line code shrinkage translating from a legacy (though still imperative) codebase is amazing, and must point to an excellent language design. Of course I realize I could probably achieve the same thing with a number of other functional languages of which i have limited experience
- octo_t 13y agoI absolutely agree (although for smaller projects I enjoy Haskell more). Tony Morris (the person who started the conversation) is a pretty devoted Scala-er. But it is definitely recognised by Scala experts (especially people who are arms deep in the compiler) that the JVM is a very limiting factor in the design of the language.
- michaelochurch 13y agoScala is a great language to write in. It's also good because you can learn a lot about the JVM (that you wouldn't learn as easily in Clojure, because the JVM interop of Clojure is less mature and far less intuitive) but also about strong, static typing in a system almost as badass as Haskell's. On the other hand, reading Scala code written by mediocre developers is painful. That's probably true of any language, but in Scala bad code comes with (a) minimal support from the IDEs that make shitty code navigable, (b) a less mature reflection API, and (c) serious compile-speed pains at scale. If anything kills Scala, it will be the the Java-in-Scala crowd-- the ones who failed to learn what Scala was really about and what it had to offer, but used it because their bosses demanded it. Scala is well-designed-- extremely so, and almost no one here could have done better in that time-- in the context of its constraints (JVM) and purpose (a Haskell-like language on a VM with a top-down type system-- radically different from the bottom-up tying approach of traditional Hindley-Milner languages). Scala-bashing gets on my nerves for two reasons. First, if you understand the compromises that had to be made, it's hard to imagine it being done better. Second, you know what happens if Clojure and Scala developers beat each other up? Managers step in and make us write Java.
- brucefancher 13y agoClojure.
- clubhi 13y agoToo succinct.
- kleiba 13y agoThe comment or the language? All kidding aside, one- or two-word comments are quite uninformative. Just because the original article with its "Scala is not a well-designed language" statement doesn't bother backing up bold claims with arguments, we should not fall into the same trap here on HN. It's worth talking about Clojure as an alternative to Scala. They're both targetting the JVM, and they're both still on their way out of a niche. But just throwing out the name of an alternative programming language doesn't make a useful comment yet, nor does the "too succinct" reply.
- rbanffy 13y ago> The comment or the language? Think about it for a second. Take a step back. Look again. It's poetry. A very concise comment, on a very concise language is followed by a "too concise" comment. It's beauty.
- Afforess 13y agoIt's fun to hate on Java (cause who here hasn't hit stupidity with Java?), but the fact is that Java does a lot right. There are two types of languages, the languages people hate and the languages no one uses.
- jlgreco 13y agoThere is a third type of language: languages that people hate so much that no one uses them anymore. For values of "no one uses" that set up the "like"/"not used" dichotomy, I'd say Perl is in both categories. With any luck Java will get there too one day, even if the JVM doesn't follow it.
- twic 13y agoWith any luck, all the languages we know today will get there too one day, as they are rendered obsolete by further decades of experience with programming languages. Well, except LISP, obviously.
- peter_l_downs 13y agoProlly the biggest advantage of the JVM in my opinion was pointed out by "iv...@ivan.net.nz": > The one thing I like about the jvm is that I can compile > and package code on one platform and deploy to another > without worrying about anything but the fact that the jvm > is installed. Solves so many headaches!
- yumraj 13y agoWhile it's not the same thing, 'go' can compile for multiple platforms, and then you can deploy appropriate binaries on another OS as long as 'go' is installed.
- burntsushi 13y ago> and then you can deploy appropriate binaries on another OS as long as 'go' is installed. Nope. Go does not need to be installed for a binary produced by the `gc` compiler to run.
- tieTYT 13y agoYes, and for how good Haskell is as a LANGUAGE, it sucks at this very important feature (assuming you want to use a 3rd party library).
- michaelsbradley 13y agoThere's always Frege: https://github.com/Frege/frege https://github.com/Frege/frege But it's definitely a work in progress.
- mjn 13y agoSun used to use the catchy slogan "write once, run anywhere" to refer to this property...
- mrhonza 13y agoYes, I agree that uberjars are a great thing when it comes to the JVM ecosystem. However, with the advent of projects like docker, I can't help but think that this reasoning is now obsolete. You can write your app in Go, Rust or Haskell and deploy it inside a container that you provide. You control the environment that it runs in.
- octo_t 13y agoSimon Ochsenreither has been investing a fair amount of resources into Avian[1], an alternative JVM with support for tailcalls and various other useful toys. I think this is possibly where languages like Scala may lead, potentially forking a JVM and refitting it to their own needs. [1] - https://github.com/ReadyTalk/avian/ https://github.com/ReadyTalk/avian/
- akurilin 13y agoInteresting, it'd be good to have community-drive alternative to the JVM, like some kind of a Postgres of VMs. Also tail calls are what people complain about with Clojure on the JVM, so this would address that problem.
- octo_t 13y agoWhen I'm done with my current project, my plan is to make the heap 64-bit on 64-bit machines (which was currently an issue last I checked).
- twic 13y agoBy "to the JVM", you mean "to the Oracle JDK". The implication that the Oracle JDK is the JVM equivalent of Oracle/DB2 is rather unfair. The Oracle JDK is really OpenJDK, which is, as the name suggests, open source. It is true that there is one behemoth corporation behind OpenJDK, but that still makes it the equivalent of Chrome or Eclipse, not Oracle or DB2.
- twic 13y agoAvian is a very impressive piece of work. I'm not sure i'll ever switch to it, but hopefully, its very existence will drive the OpenJDK to improve itself to compete (eg adding tail call optimisation). A bit like how Scala forced Java's hand in adding lambdas.
- bitcrusher 13y agoThere are really several layers of issues to deal with in regards to the JVM. First, the JVM really IS NOT a great choice to build other languages on. It wasn't designed for it; In fact before invokedynamic, it was nearly impossible. For all intents, building other languages on the JVM is a bad hack, regardless of how elegant ( or not ) the language syntax is. The amount of fuckery required is nearly unbelievable. Second, the JVM is owned by Oracle. It is technically 'open source' but Oracle has proven time and again to not only be against open source, but one could even support the position that they're actively hostile towards it. Ideally, the solution would be to invest engineering mind-share into creating a REAL VM that was designed to host many programming languages. Regardless of what you think of Microsoft, they got .Net correct in that their tooling infrastructure was built from the beginning with multiple programming languages sitting on top of the CLR ( and later the DLR ). The LLVM folks have been making some progress in this regard by way of VMKit, but personally I cannot understand why this issue doesn't get more mind-share. Python, Scala, Ruby, Clojure, Lua, etc would all benefit in the end.
- Pxtl 13y agoThey tried. Does nobody else remember Perl 6/ parrot?
- ishbits 13y agoSo what are my real options for avoiding the JVM on new projects? Go? I'm not into functional save a bit if Scala. But not willing to invest time in something like Haskell. I also don't feel like Python is an option. Seeking more performance from a single node is what he me move to Java from Python for many of the the things I work on.
- eccp 13y agoI think it's easy to feel overwhelmed but you probably can scale up with Python with little effort with PyPy (time ago you could do that with Psyco) or change your processing to something based on Twisted.
- jerf 13y agoWithout even a hint of what you want to do with your "new projects", that's not possible to answer. Python is a sensible answer for many cases, for instance. Go is pretty plausible for some projects but would immensely weak for others (for its age, it has great library support, but it is still a young language), etc. C++? D? Ocaml? C#, perhaps on Mono? How exotic are you looking to be? In the rich, diverse world of programming languages, the JVM is merely one participant. It's large, but I do not think everything else merely lives in its shadow or anything, it is not that dominant. Not even close, really. (C++ may once have stood atop the world, but nothing else has quite pulled that off since.)
- PommeDeTerre 13y agoC and C++ are still the dominant languages, by far. They're still actively "standing atop the world". Almost everything truly important today is written in one of them, or both of them. The usable, production-grade implementations of PHP, Python, Ruby, JavaScript, Lua and Perl depend on one or both, as well. Most JVM implementations depends heavily on them, too. When they're providing the foundations necessary for even their competitors or alternatives, it inherently makes them even more valuable and effective.
- dragonwriter 13y ago
- skybrian 13y agoI think you have to start with your target platform. If you want to run in the browser it has compile to JavaScript. That has consequences. If you're targeting mobile phones it has to generate Android or iOS code, preferably both. On the server there are many more choices; targeting LLVM might be a good bet. Language design is important, but being a good fit for the platform is more important.
- Pxtl 13y agoCome to the dark side. C# has been awsome since about 3.5
- happy_dino 13y agoI don't think C# is even remotely able to compete in this battle. :-)
- rbanffy 13y agoWhile C# runs on platforms other than Windows, those platforms have such incredibly rich programming ecosystems one has to wonder why would anyone program in C# for them when there are hundreds of languages more appropriate to the specific problem.
- kvb 13y agoHundreds of languages? I don't know, Xamarin's tools seem to indicate that there's a real demand for using C# on a variety of platforms. While not my personal preference, C# is really a wonderfully well-designed language.
- profquail 13y agoIf they're going to switch from the JVM to the CLR, they might as well switch to F#; in fact, I'll even argue it'd be easier for them to switch to F#, since they'll be able to continue using many of the functional programming concepts and abstractions they've already learned in Scala.
- Pxtl 13y agoFor a multiparadigm langauge, C# 3.5 and up offer some solid functional programming stuff. Obviously if you want to go hardcore into FP you can find it in F#, but if you just want to do lots of awesome things with lambdas using otherwise-conventional OOP, C# is surprisingly well-equipped. A lot of C# developers are stuck treating it as Microsoft Java, which it hasn't been for several years. To me, the biggest problem with C# is cultural. C#'s user-community is entirely enterprisy... it's open-source adoption has been minimal, and that means that most C# code is still heavily stuck in a "cathedral" mentality where coders either use exclusively Microsoft libs (which are often terrible - no single company can ever be expected to get it right every time) plus some heavy wheel-reinventing, or maybe they pick up some gigantic vendor-backed 3rd-party lib like Telerik. There isn't the massive community of open-source developers like you see on other platforms.
- rbanffy 13y agoSeriously, I stopped reading on "1) Scala is the best available programming language for the JVM." There is no such thing as "best programming language". A programming language either fits your problem, making if comfortable to express your program with it, or it doesn't.
- PommeDeTerre 13y ago"Best" doesn't necessarily mean "perfect" or "optimal". You can easily be given several choices that are all imperfect or suboptimal. But of those choices, there could very well be one that isn't as imperfect or suboptimal as the others are. This one can be considered the "best". That's pretty much the situation here. Given that the major players in this arena are Java, Clojure and Scala, we often find Scala coming out ahead in most measures. In this context, it can be said to be "the best".
- sultezdukes 13y agoI think the OP was referring to the fact that "best" is subjective. Obviously many, many others don't think that Scala is the "best" programming language on the JVM. Given that the major players in this arena are Java, Clojure and Scala, we often find Scala coming out ahead in most measures. The "we" in the above sentence refers to you and some other people that might have that sentiment, but not lots of other people.
- rbanffy 13y agoNot only that, but claiming Scala is the best programming language for the JVM is like claiming Vala is the best programming language for Gnome. It's childish.
- PommeDeTerre 13y agoThis isn't about my opinion or preferences. This is about looking at the reality of the situation. Java (the language) is quite heavily used, but this is more a factor of it merely being around for years, and the huge amount of hype it received during its first decade of existence. However, it is now widely accepted that it is significantly deficient in many ways, which is part of the reason that people are seriously looking to alternatives. Clojure may be a major player within the context of modern Lisp-like languages, but beyond that it's extremely obscure, and it is not widely used at all. At least part of this obscurity is due to its syntax and semantics. Time and time again we've seen this approach rejected by the software development community as a whole, regardless of whether we're talking about Lisp, Scheme, Common Lisp, and now Clojure. It's just not what people want. So Scala ends up being the one with the fewest drawbacks, and the most positive aspects. It has a far more familiar syntax and semantics, it is seeing actual real-world use, and it does have features and functionality that attract people toward using it. From an objective viewpoint, it is the best of the given options.
- michaelochurch 13y agoI'm sorry, but I think calling Scala "not well designed" is a bit off the mark and smells of flame-bait. Relative to the extremely hard problem of putting a Hindley-Milner type system on top of the JVM, I think it's extremely well-designed. I probably prefer Clojure slightly, but Scala-bashers are missing the fact that, for what Scala is trying to do, it does it extraordinarily well. Now, I don't like object-oriented programming at all so I question the utility of that aspect of JVM support-- Clojure's doing a much better job of making that stuff the weird-looking clunky part-- but Scala does a damn good job with what history handed it.
- srean 13y agoPeople here might like to take Felix for a spin. http://felix-lang.org/share/src/web/tutorial.fdoc http://felix-lang.org/share/src/web/tutorial.fdoc http://felix-lang.org/share/src/web/nutut/intro/intro_index.fdoc http://felix-lang.org/share/src/web/nutut/intro/intro_index.... All analogies are inaccurate, so with such inaccuracies assumed, one can look at Felix as: Felix is to C++ what Scala is to Java, but that is is not a very illuminating comment. To give an idea, Felix is a whole program optimized, strongly typed, polymorphic, ML like language that can interact effortlessly with C and C++ code and has coroutines baked in. It uses a mix of lazy and eager evaluation for performance and compiles down to C++.
- jongraehl 13y agoWhat's wrong with it, then? Such a language would need: 1. tool support (valgrind, gdb or better) 2. good performance - 64-bit on the major desktop OSes (mobile a plus, obviously) 3. real concurrency 4. libraries 5. build time for large projects ("compiles down to C++" makes me think this could be an issue) Most new languages fail at several of these, for years. You'll notice that I haven't mentioned language design at all.
- srean 13y agoIt scores extremely, extremely well on 2. Regarding 3 it has had coroutines built into the language since the last 10~15 years, much before the language Go made it more mainstream. preemptive threads is more recent. It does have a stop the world garbage collector, which is not good for concurrent applications, but the semantics allows one to avoid creating garbage to a large extent. Libraries is chicken and egg, one needs higher level of adoption to drive this. 5 could be a legitimate concern, but I dont think its going to be any worse than Scala or C++ in this respect. As far as language design goes, Skaller the author is a well regarded PL theorist active on LTU. I am not saying this the best, end all language, but one that has enough interesting features that would be interest to the early-adopter rich crowd that we have here. It certainly has grabbed my eye balls
- jongraehl 13y ago
- kvb 13y agoWhile there's plenty to disagree with, it pains me to see such rich fodder for an interesting discussion on the design, implementation, and adoption of programming languages languish on the second page of HN while the first page still has a dozen NSA stories.