Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
C# has first-class functions, LINQ, awesome language/framework support for threads and asynchrony, and the best IDE on the market.

Java feels like it's stuck in the stone ages after working with C# for so long.

Adbot
ADBOT LOVES YOU

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
I agree, I think C# is a whole generation ahead on language features compared to Java. My point was really just that despite being aware that Java is a fine language and ecosystem and working in its spiritual successor for the last several years I'm constitutionally incapable of reading Java code.

Dietrich posted:

I have very few complaints about C# as an ecosystem.

Some of the really old stuff isn't implemented with generics, which would make it work a lot better.

That's pretty much it.

The only real WTF I've run into in the core framework had to do with reading non-blocking I/O from a Process object. The API System.Diagnostics.Process provides is a catch-22. I don't remember the exact details but it was something like you either have to block and guarantee you get all the bytes it's outputting or you can not block but there's no guarantee you get all the bytes, no indication you did or did not get all the bytes, and the handle is dead immediately after polling it once.

I suspect the wtf has its roots in something crazy Win32 is doing that the .NET layer couldn't adequately abstract around but it's the only place I've run into .NET where it feels like MS threw up their hands and said gently caress it who needs to do this anyway.

edit: actually that's not true. WCF, especially the first release in .NET 3.0 had its share of complaints, including breaking the IDispose contract for all generated service clients.

WCF also had a problem, common in the MS ecosystem, where they ship a comprehensive framework to last generation's solutions just in time for the next generation of How Things Are Done to take over (e.g. WCF shipped out of the box for SOAP over every protocol imaginable just in time for the rise of lightweight POX/REST services over HTTP to become the new thing).

Dr Monkeysee fucked around with this message at 20:20 on Oct 2, 2013

Posting Principle
Dec 10, 2011

by Ralp
The problem with C# is Windows.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
Use Mono.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Mono is still/was significantly(?) less good than the CLR, though. For example, I know I've heard of code that works great in C# having terrible memory leaks in Mono because its GC could only detect dead objects as actually dead if they had no connections to anything, including other dead objects. Basically, it was strait-up reference counting in the dumbest possible way. Maybe they've fixed that by now, but it wasn't more than 2 years ago that I read this. Hell maybe they were using an old version of Mono - the point is that it's not 100% on all platforms just because of Mono like Java is because the JVM is everywhere.

Now I'm wondering why the original Mono team didn't target the JVM :\

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
Mono 3 was released about 2 months ago and one of their major bullet points is a complete overhaul of GC. It's definitely not 100% but it's pretty good in many cases. These days they seem to be focusing mostly on cross-platform mobile development which sounds like a pretty good niche. Unfortunately MS are butts about certain parts of the framework so some stuff is just missing or poorly reverse-engineered because ~*fair use restrictions*~.

The relationship to the open-source community is something Sun got very right about Java and MS is still really haphazard and of several minds about. It's a bit of a licensing mess.

Munkeymon posted:

Now I'm wondering why the original Mono team didn't target the JVM :\

My completely uneducated guess is .NET IL and Java Bytecode don't have enough in common to make this viable. A .NET assembly written on the MS CLR will run without recompilation on the Mono CLR and vice-versa. I doubt that would be possible if Mono's "CLR" was the JVM.

Dr Monkeysee fucked around with this message at 20:39 on Oct 2, 2013

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde
Well Java has one over C# in that enums can have properties, methods and constructors, which can be handy sometimes.

Re: C#, the 1.0/2.0 APIs feel a bit janky or inconsistent in parts. Some methods return strings, some methods return DirectoryInfo/FileInfos, it's not obvious from the name if something will return a trailing slash or what, the full Win32 api for process manipulation isn't exposed in the Process class, so if you need some specific functionality, holy balls you end up writing a lot of extern stuff and re-implementing the Process class (which is not easy). There's no nice way of taking the redirected Console.Out and Console.Error (which aren't actually STDOUT/STDERR annoyingly) and merging them so the output is definitely in the order they were written to.

More recently, I think the async/await and TPL is a bit leaky in terms of abstraction - there's lots of subtleties going on under the hood that you need to understand and you can easily end up screwing yourself over unintentionally (think of ConfigureAwait synchronization deadlocks when you use TPL code in a GUI.)

Lack of customisation around the JIT or the GC. The relatively massive penalties incurred in short lived .NET apps if you try to access the ConfigurationManager.AppSettings. Not being able to change the default app domain's DLL search path. Interactions between app domains being fairly messy and an absolutely stellar way to gently caress yourself over with type serialization issues if you don't know what you're doing. Custom exceptions (so deriving from Exception) not being Serializable by default, leading to misleading exceptions if an exception crosses an app domain boundary (for the love of god, never write custom exceptions).

Libraries and their handling of Xml namespaces, including the default one. The 1.0 library is bad, but the XDocument / XPath stuff isn't much better. NamespaceTableManager and all that bollocks. 99% of the time, we don't care.

WPF needs streamlining and bugs being fixed in controls (Accordion control in designer mode has been broken for years now, throws NREs). Language features / extensions to make multi-field validation, or edit/revert/mark as unsaved not a complete PITA full of boilerplate to do.

I very much enjoy working with C#, but I do sometimes wish they could throw out a lot of the window and start again.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
The whole W*F generation of frameworks all seem to suffer from severe architecture astronautics, now that I think about it. WCF, WPF, etc. are (or were) all very difficult to use out of the box for anything useful and are generally unhelpful when things go sideways.

However I've always found the core framework to be clean and straight-forward (except some of the pre-generics stuff).

Milotic posted:

Well Java has one over C# in that enums can have properties, methods and constructors, which can be handy sometimes.

You can get around this for many use cases via extension methods. It's not as full-featured as Java enums though.

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde

Monkeyseesaw posted:

The whole W*F generation of frameworks all seem to suffer from severe architecture astronautics, now that I think about it. WCF, WPF, etc. are (or were) all very difficult to use out of the box for anything useful and are generally unhelpful when things go sideways.

Windows Workflow Foundation was the flakiest piece of crap ever and was even flakier when added to SharePoint (which also suffers from architecture astronautics and being firmly in the ASP.NET WebForms camp rather than the MVC camp). WPF always suffered from issues whereby something that you think would be easy or even built into a default control, turned out to be super-hard. And the whole DependencyObject/DependencyProperty malarkey was a bad abstraction. I get that they allegedly did it for performance, but WPF perf is kinda bad anyway, but you end up having to do lots of boilerplate around DO/DPs which wasn't always easy to remember. Biggest issue with WPF is that drag/drop and similar user interactions don't behave exactly the same as Windows Explorer - you had to write custom code to approximate it.

I think Microsoft have gotten a lot better at this stuff recently. Doing out of band releases means things can be polished and don't hold up VS releases and vice versa. (Also there is a bigger expectation that libraries can change fairly dramatically until the first proper RC)

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Monkeyseesaw posted:

The whole W*F generation of frameworks all seem to suffer from severe architecture astronautics, now that I think about it.

Don't ever look into EF. That is a convoluted bag of suck.

Yes, let's replace something that actually worked for quick and dirty applications with something that will take you hours to configure.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Monkeyseesaw posted:

Mono 3 was released about 2 months ago and one of their major bullet points is a complete overhaul of GC. It's definitely not 100% but it's pretty good in many cases. These days they seem to be focusing mostly on cross-platform mobile development which sounds like a pretty good niche. Unfortunately MS are butts about certain parts of the framework so some stuff is just missing or poorly reverse-engineered because ~*fair use restrictions*~.

The relationship to the open-source community is something Sun got very right about Java and MS is still really haphazard and of several minds about. It's a bit of a licensing mess.

I keep hoping that someone at Microsoft will get a clue and organize a team that does nothing but work on Mono all day under pseudonyms.

quote:

My completely uneducated guess is .NET IL and Java Bytecode don't have enough in common to make this viable. A .NET assembly written on the MS CLR will run without recompilation on the Mono CLR and vice-versa. I doubt that would be possible if Mono's "CLR" was the JVM.

I wasn't thinking it'd be a compile-once-run-everywhere solution but at least they'd have the language on a solid, mature VM instead of spending 8(?) years getting theirs close.

E: thought about it and it should have been possible, given an open source C# -> JBC compiler to write an open source MSIL decompiler (like ILSpy) and chain them together into a fragile, undebuggable C# to JVM compilation suite :v: Then you could work on going straight from MSIL to JBC because if you can go from MSIL -> C# -> JBC, you should be able to skip the first step.

Munkeymon fucked around with this message at 21:53 on Oct 2, 2013

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde

Dessert Rose posted:

Don't ever look into EF. That is a convoluted bag of suck.

Yes, let's replace something that actually worked for quick and dirty applications with something that will take you hours to configure.

EF meaning Entity Framework? It really doesn't take hours. What version are you thinking of? It's gotten more streamlined since 4.0, but even 4.0 was easy if you use the Wizard. In fact I would consider it the go to choice for quick and dirty CRUD applications driven by humans (it's less suited to read-heavy server apps). What specific issues are you thinking of?

Pollyanna
Mar 5, 2005

Milk's on them.


Soricidus posted:

or Python (it's much more likely that a random computer will have a JVM than a Python interpreter)

Why not just freeze the Python program into a binary?

And I'd look into C# more, but I don't see a way to program C# on OSX...edit: Oh Mono exists.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Milotic posted:

EF meaning Entity Framework? It really doesn't take hours. What version are you thinking of? It's gotten more streamlined since 4.0, but even 4.0 was easy if you use the Wizard. In fact I would consider it the go to choice for quick and dirty CRUD applications driven by humans (it's less suited to read-heavy server apps). What specific issues are you thinking of?

Maybe I'm just averse to using wizards to generate a bunch of code for me, but it seemed a lot more heavyweight when all I wanted to do was grab some objects out of a database with some foreign key relationships.

I mean, it worked, I just felt like L2SQL took me less effort to get working. The wizard is hard to use when you're writing code on a machine that doesn't have direct access to the DB you're trying to code against, for one. I had to dump the DB and restore it to a local SQL instance first.

Dessert Rose fucked around with this message at 23:02 on Oct 2, 2013

ijustam
Jun 20, 2005

If you don't have a DAL and you're using EF over multiple solutions, you're going to have a bad time.

I know.

QuarkJets
Sep 8, 2008

Soricidus posted:

I seriously use Java to write client software today. :(

It can have some genuine advantages in that space, when you don't have any control over the target environment. For example, deploying a JAR is trivial compared to C++ (compile a different version for every user platform? no thanks) or Python (it's much more likely that a random computer will have a JVM than a Python interpreter). I can literally email a single file to a new user and be confident that they can just double-click on it and the application will appear on their screen. I don't know of any other technology that offers that.

Basically, if you still need to write desktop software at all, Java isn't actually a terrible choice for that.

Distributing Python and Java are pretty similar in that both require some sort of runtime environment. I don't see how it's reasonable to expect a user to have access to a JRE but not expect them to have access to a Python interpreter

Or as Pollyanna said, if you're worried about it then create a binary

Pollyanna
Mar 5, 2005

Milk's on them.


OSX even comes with Python installed.

redleader
Aug 18, 2005

Engage according to operational parameters

Monkeyseesaw posted:

My completely uneducated guess is .NET IL and Java Bytecode don't have enough in common to make this viable. A .NET assembly written on the MS CLR will run without recompilation on the Mono CLR and vice-versa. I doubt that would be possible if Mono's "CLR" was the JVM.

Well, there's IKVM which allows you to call Java code from .NET. One of our clients considers it to be a sensible and production-ready project. I have no idea if the converse (running .NET on the JVM) is possible or how hard it would be.

It's a weird feeling, opening up a C# file to see things like
code:
using System;
using com.java.whatever;
and knowing that you're somehow running a bunch of Java on the CLR.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
I would really love Mono becoming an official MS-supported runtime and it really would be a way to push .NET forward. Alternative: Take the official CLR and port it to all relevant platforms. Shame it won't happen :(

Omnomnomnivore
Nov 14, 2010

I'm swiftly moving toward a solution which pleases nobody! YEAGGH!
A developer at my job has decided based on some thing he got off the web that all our python scripts should have this:
code:
if __name__ == '__main__':
    try:
        main()
        sys.exit(0)
    except KeyboardInterrupt, e: # Ctrl-C
        raise e
    except SystemExit, e: # sys.exit()
        raise e
    except Exception, e:
        print 'ERROR, UNEXPECTED EXCEPTION'
        print str(e)
        traceback.print_exc()
        os._exit(1)
I don't know what I hate most about this: that it puts the stack trace on stdout instead of stderr, that it makes it impossible to do post-mortem debugging, or that it basically re-implements what the interpreter does anyway only more crappy. He's still advocating that we use it everywhere "because it allows you to catch top-level exceptions and do something about them", but can't seem to say what that "something" is.

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures

Bognar posted:

Microsoft's own web hosting software is incorrectly classifying Microsoft's own browser. So our application would send Set-Cookie headers, IE 10 would send them back on each request, but IIS would completely ignore them - thus rendering IE 10 users unable to log in.

:bang:
Was this the occasion they were parsing only the first character after the string "IE " to determine the browser version, and so concluding it was "IE 1"?

Hughlander
May 11, 2005

Bognar posted:

Holy hell I hate Microsoft.

We just switched one of our client's ASP.NET MVC websites to run on a new server. Everything went pretty smoothly, until we started getting e-mails this morning about users not being able to log in on IE 10. We didn't change any code and we copied the configuration settings from the old server, so things shouldn't have changed.

After spinning for a few minutes trying to figure out why only IE 10 was affected, I went a Googling. As it turns out, IIS 7 and below consider IE 10 to be a cookieless browser.

Microsoft's own web hosting software is incorrectly classifying Microsoft's own browser. So our application would send Set-Cookie headers, IE 10 would send them back on each request, but IIS would completely ignore them - thus rendering IE 10 users unable to log in.

:bang:

Was the horror that your 'upgrading the server' downgraded the server software to something older than 5 years old? (I'm assuming on the older server it worked and therefore was running IIS 7.5 or above which was released with Windows 7/Server 2008SP2?)

Cached Money
Apr 11, 2010

Check out my school java project, kinda shows what the level was there: http://pastebin.com/WDA6GrLJ
Sad thing is, I'm not much better now.

Edit: Also just noticed all the comments are in scandinavian moon language except the one at the top.

Edit 2: It's a terrible shmup, btw.

Cached Money fucked around with this message at 19:20 on Oct 3, 2013

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Cached Money posted:

Check out my school java project, kinda shows what the level was there: http://pastebin.com/WDA6GrLJ
Sad thing is, I'm not much better now.

Edit: Also just noticed all the comments are in scandinavian moon language except the one at the top.

Edit 2: It's a terrible shmup, btw.

To be fair, my version of tetris from school was probably about as good as this. Everyone is terrible while they're still in school.

Pollyanna
Mar 5, 2005

Milk's on them.


Cached Money posted:

Check out my school java project, kinda shows what the level was there: http://pastebin.com/WDA6GrLJ
Sad thing is, I'm not much better now.

Edit: Also just noticed all the comments are in scandinavian moon language except the one at the top.

Edit 2: It's a terrible shmup, btw.

Anal Asteroider? :haw:

God, I really should just bite the loving bullet and learn Java. I just hate how it's so verbose, it's like the Aspergers of programming languages. At least once I'm done I can move on to Scala.

edit:

quote:

In Java, every line of code that can actually run needs to be inside a class.

:sigh:

Pollyanna fucked around with this message at 23:51 on Oct 3, 2013

GottaPayDaTrollToll
Dec 3, 2009

by Lowtax

Heavy_D posted:

Was this the occasion they were parsing only the first character after the string "IE " to determine the browser version, and so concluding it was "IE 1"?

Should've called it IE A.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Pollyanna posted:

I just hate how it's so verbose, it's like the Aspergers of programming languages.

Sounds like someone has never heard of Ada.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
https://www.youtube.com/watch?v=xrIjfIjssLE

Pollyanna
Mar 5, 2005

Milk's on them.


quote:

This is the entry point of our Java program. the main method has to have this exact signature in order to be able to run our program:

Java code:
public class Main {
    public static void main(String[] args) {
    }
}
public again means that anyone can access it.
static means that you can run this method without creating an instance of Main.
void means that this method doesn't return any value.
main is the name of the method.

What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on.

Also, the interactive tutorial on learnjavaonline.org errors out when you try to complete the exercise. Bodes well for me.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Well, you see, object-oriented purity therefore everything must be a class, however practical considerations therefore static methods.

Pollyanna
Mar 5, 2005

Milk's on them.


I love how there are numerous projects out there dedicated to writing for Java in completely different language. Not even Java users like Java.

zeekner
Jul 14, 2007

Pollyanna posted:

What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on.

Also, the interactive tutorial on learnjavaonline.org errors out when you try to complete the exercise. Bodes well for me.

Because it's not a scripting language? Single-file scripts or REPL might be nice for beginners, but Java is better off by enforcing that structure.

e:

Pollyanna posted:

I love how there are numerous projects out there dedicated to writing for Java in completely different language. Not even Java users like Java.
That speaks more to the flexibility and power of the JVM than any inherent weakness of Java.

Posting Principle
Dec 10, 2011

by Ralp

Pollyanna posted:

What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on.

They are magical incantations to make the code run faster.

leftist heap
Feb 28, 2013

Fun Shoe
Most compiled languages have some sort of machinery needed to write a main method. Hardly a coding horror.

Pollyanna
Mar 5, 2005

Milk's on them.


I guess I just don't really understand what's so special about Java aside from the JVM. That or I'm just clueless. This might be the fabled difference between functional and object-oriented programming.

rrrrrrrrrrrt posted:

Most compiled languages have some sort of machinery needed to write a main method. Hardly a coding horror.

What's wrong with writing in a higher-level format then using a program to convert it to pre-compile code?

leftist heap
Feb 28, 2013

Fun Shoe

Pollyanna posted:

I guess I just don't really understand what's so special about Java aside from the JVM. That or I'm just clueless. This might be the fabled difference between functional and object-oriented programming.


What's wrong with writing in a higher-level format then using a program to convert it to pre-compile code?

That's... exactly what you're doing. Would you rather write the JVM bytecode directly?

edit: There isn't anything special about Java aside from the JVM. Java is a warty, mediocre (though probably overly-maligned) programming language. The JVM, on the other hand, is one of the most sophisticated, mature and widely-spread programming platforms in existence.

leftist heap fucked around with this message at 01:08 on Oct 4, 2013

Pollyanna
Mar 5, 2005

Milk's on them.


rrrrrrrrrrrt posted:

That's... exactly what you're doing. Would you rather write the JVM bytecode directly?

edit: There isn't anything special about Java aside from the JVM. Java is a warty, mediocre (though probably overly-maligned) programming language. The JVM, on the other hand, is one of the most sophisticated, mature and widely-spread programming platforms in existence.

Cool. So why not write in another language like Scala, Jython or Clojure and have that run on the JVM instead?

zeekner
Jul 14, 2007

Pollyanna posted:

Cool. So why not write in another language like Scala, Jython or Clojure and have that run on the JVM instead?

Because Java isn't inherently bad? You can write bad java, but you can write terrible code in any language. Not every line of java is Enterprise AbstractFactoryImplInterface bullshit, and I never run into that in my day-to-day work.

Hell, most of your earlier complaints are minor squabbles that apply to all lower-level languages. The funny thing is, your complaints are based around "Efficiency", but most of these restrictions and annoyances only exist to make the language run as efficiently as possible.

leftist heap
Feb 28, 2013

Fun Shoe

Pollyanna posted:

Cool. So why not write in another language like Scala, Jython or Clojure and have that run on the JVM instead?

I don't know? Why aren't YOU using one of those languages? They will all require similar boilerplate to get an executable main method:

In Clojure:

code:
(ns clojure.examples.hello
    (:gen-class))
 
(defn -main
  (println (str "Hello World!")))
In Scala:

code:
object Main extends App {
  Console.println("Hello World: " + (args mkString ", "))
}

Adbot
ADBOT LOVES YOU

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Pollyanna posted:

What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on.
So why aren't you using HQ9+ instead?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply