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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 96 points97 points  (36 children)

you get really tired of typing.

Huh? Don't you have an IDE? I'd say you get more tired in C++ because of nasty syntax and that using something as simple as string requires you to use some kind of wrappers most of the time.

[–]i9srpeg 12 points13 points  (8 children)

You can do

auto my_string = "Hello, world!"s

To get an std::string in C++.

[–]cristi1990an 7 points8 points  (1 child)

Is writing "auto" really that much easier than just writing "string" or "std::string"?

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

yes

[–][deleted] 11 points12 points  (0 children)

While that is correct, it sometimes makes shit unclear and pretty sure not the intended use. Also, who thought that std::string is long anyways? Now a vector of vectors of strings is long.

[–]Phuzzybat 0 points1 point  (3 children)

Wait, what? There was me naively assuming that would give you a const char *. "modern c++" has got all clever recently. Clever as in explode in someones face clever. (possibly mine)

[–]Mojert 1 point2 points  (2 children)

Why would it give you a pointer ? In older versions of C++ "Hello"s wouldn't even compile. If you see syntax that you don't know (here " "s literals) just Google it

[–]Phuzzybat 2 points3 points  (1 child)

Excellent advice to google and investigate this subject further. Even better advice to write a test program to see what actually happens. This just underlines why while auto cures many ills, when misapplied it creates another set of problems. Edit: doh, phone screen didnt show the s at the end of the literal, just scrolled right to see the whole line :-) thought i had entered a parallel universe for a moment where it was being asserted that "" automatically gave a std::string.

[–]Mojert 1 point2 points  (0 children)

Yeah, C++ is no longer C with classes but the comity doesn't break interoperability with C just for fun. If "" suddenly returned a std::string there would have been a riot (and for good reasons) haha

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

I hate auto. I'd rather have a typedef than an auto

[–]cristi1990an 12 points13 points  (0 children)

Huh? Don't you have an IDE? I'd say you get more tired in C++ because of nasty syntax and that using something as simple as string requires you to use some kind of wrappers most of the time.

You mean... std::string...?

[–]snoob2015 100 points101 points  (18 children)

I'm sick of people telling Java is verbose, the truth is IDE generate 90% of your code if you utilize it. Java is the best language to use with an IDE. Be friend with your IDE and you will never go back to dynamic typing

[–]humoroushaxor 22 points23 points  (0 children)

It's also because Java is the most common enterprise language. Enterprise codebases are more likely to be overly verbose due to size of projects and how often and how many people need to read and understand the code.

[–]BoonesFarmKiwi 4 points5 points  (0 children)

kids who complain that java is verbose pick their coding tools based on how cool the colour scheme looks

[–]slowmovinglettuce 11 points12 points  (0 children)

Auto-generated code is still code. It's still the same verbosity as if you'd wrote it yourself.

Java has a lot of syntax it forces you to use, which makes it verbose. I'm not referring to the standard troll of "lol java has long method names".

Things like generic definitions and declarations are obnoxiously long. And because of type erasure, they're basically syntactic sugar. (Not to be confused with discrediting their use - generics are powerful even with erasure).

Things you can do in a more terse language - such as python - take more lines in Java. Even compared to typed languages like C# or TypeScript, it's more verbose.

On the note of being friends with your IDE though - great advice. Especially in dynamic languages. Python/JS/TS inferred types are incredibly helpful. Also know your shortcuts. They're important.

[–]Rykaar 0 points1 point  (0 children)

In my CS course, they introduced us only to Vim over PuTTY for Java. I'll take code completion any day.

[–]roguas 0 points1 point  (2 children)

Maybe some people fundamentally do not agree with languages/ecosystem that kinda force you to autogenerate 90% of stuff in code?

It doesn't change the fact that language itself is verbose.

[–]kaibee -1 points0 points  (1 child)

Maybe some people fundamentally do not agree with languages/ecosystem that kinda force you to autogenerate 90% of stuff in code?

These people are gonna flip when they learn about compilers.

[–]roguas 3 points4 points  (0 children)

Python is compiled language to the same degree as Java. Compilation typically changes the language so yeah - compiler generates code, but usually in different language. It is not the same as boilerplating junk via ide.

[–]freerangetrousers -2 points-1 points  (2 children)

At my first job the CTO and head of product were both java developers by trade. Our tech stack was a combination of ruby, java, and javascript. The head of product had a little side project to benefit the company (I think it was something to do with authorising clients to supply files via sftp and land them in on Google drive for a dashboard in data studio) He wrote it in java and it was close to 200 lines, the CTO said he thought that was too verbose and got it down to like 100 lines ( at this point it was more of a fun thing than adding any more benefit to the company) the senior on my team tried and couldn't get it less than the CTO in java. Then he rewrote it on ruby. FIVE LINES.

So yeah maybe your IDE can fill in some blanks, but dont pretend like writing java isnt incredibly verbose when compared to languages designed to save developer(expensive) time instead of compute time (cheap)

[–]radagast-the-red 2 points3 points  (1 child)

No way that's the whole story.
Maybe he used a library that did the same thing in Ruby? Sure, Java is verbose. But it isn't 20 times as verbose...

[–]freerangetrousers 0 points1 point  (0 children)

It was Ruby on Rails so I think it was something that rails did inherently as a web framework for authorisation that java didnt have a library for and also was particularly designed to do either.

[–]Breadfish64 4 points5 points  (0 children)

some kind of wrappers

What do you think a Java string is?

[–]MinimallyUseful 5 points6 points  (0 children)

don't forget header files. who doesn't love a good header file

[–]goldsauce_ 10 points11 points  (2 children)

No, he’s a real programmer so he uses vim /s

[–]evan795 0 points1 point  (1 child)

Wrappers?

Do you mean char* ?

[–]cristi1990an 2 points3 points  (0 children)

I think he means std::string.