• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

The Key To Java's Success?

 
Bartender
Posts: 9612
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simplicity. Which is funny, because I can write some seriously cryptic code...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the time that Java was created, it was mainly simplicity compared to C++.

In C++ you can write code that is orders of magnitude more cryptic than in Java. Using template metaprogramming you can write a complete program that runs at compile-time.
 
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, but once you see idiomatic Scala...
 
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't lived if you have only programmed in infix. Try prefix (e.g. Lisp) and postfix (e.g. Forth).
 
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesper de Jong wrote:you can write a complete program that runs at compile-time.



I remember some 30 years ago the winner of the Obfuscated C Competition in the "shortest program" category, with a "worst abuse of the rules" flag, was simply "#include /dev/keyboard".
 
Saloon Keeper
Posts: 21598
147
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Actually, I was heavily into Forth back when my PC was a 4MHz Z80 with 24KB of RAM. It allowed me to do all sorts of fun things with the hardware. I wrote my own interpreter.

And in Forth the compiler is built into the interpreter.
 
Campbell Ritchie
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely that is
Forth good = .
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Yeah, but once you see idiomatic Scala...


I dunno. Some Scala is totally impenetrable, all that type algebra voodoo. But you can certainly use Scala as "a better Java", which cuts out a huge amount of boilerplate, without disappearing down the monadic rabbit hole. Although I'm still trying to get beyond writing idiotic Scala.

For me, Java's big strengths were: no pointers!, JVM, garbage collection. As an OO language it was easier than C++ but much less "simple" than Smalltalk, for example. But anybody who seriously thinks Java's strength is its "simplicity" needs to just grab a beer, sit down and watch Rich Hickey's classic talk on Simple Made Easy. Tune in, turn on, and drop out of the whole Algol family!
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Surely that is
Forth good = .


Hmm. Strong the Forth is in this one...
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chris webster wrote:

Bear Bibeault wrote:Yeah, but once you see idiomatic Scala...


I dunno. Some Scala is totally impenetrable, all that type algebra voodoo. But you can certainly use Scala as "a better Java",


Yes, you can, but no one seems to. I wanted to like Scala, really I did. But what I found off-putting was the community attitude of applying shortcut after shortcut to find the least amount of characters to express a statement. At that point, it's complete gobble-dee-gook to all but the Scala veterans. Cleverness trumps clarity. And I felt that newbies are sneered at. Others may have had a different impression, but that's what I felt and so gave up on Scala.

Sure you can write impenetrable code in any language*, but the impression I got from the Scala community is that (what I call) Obfuscation Through Brevity is an honored tradition. That is so not me.

But this is not meant to bash the Scala-liking, if it works for you, go for it. It just doesn't work for me.




* Some of the JavaScript I've seen lately makes me openly weep.
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know what you mean, Bear, but I think that's changed as more people have started using Scala. The "priesthood" are still around, but they're no longer the dominant feature of the community, and these days there are lots of people offering help to newbies and looking at ways to make Scala accessible to regular developers.
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just remembered that Dick Wall (prominent member of the Scala world) shared his three laws of code at the Scala Exchange conference last year:

1. Code must work
2. Code must be simple
3. Code can be clever, but not at the expense of rules 1 and 2

I think those are pretty good guidelines for coding in any language!
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chris webster wrote:1. Code must work
2. Code must be simple
3. Code can be clever, but not at the expense of rules 1 and 2


Yes, manytimes in past I tried to be extra smart to write a code which seemed clever, but at the end I found that it has lost simplicity.
Now everytime I code, i will remember these 3 rules.
 
Campbell Ritchie
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chris webster wrote: . . . Rich Hickey's classic talk on Simple Made Easy. . . .

I liked the presentation; I notice about 15′ in he talks about reasoning about programs, which is one of the things I have been doing these last few years.
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is with some people's definition of "simple".

That's why I use the word "clarity", which I notice appears nowhere in that list.
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:The problem is with some people's definition of "simple".

That's why I use the word "clarity", which I notice appears nowhere in that list.


You're a hard man to please, Mr Bibeault!
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but I have the scars from being burned too many times. I can't tell you how many times somebody's tried to explain their overly-abstracted, overly-minified code and say "See! So simple!"
 
lowercase baba
Posts: 12792
51
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know nothing of scala, but I have to agree with Bear..."Simple" can mean "brief" or "short". By some arguments, the variable name "a" is much simpler than "assetNumber", but also much less clear.
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, fred captures my point exactly; "simple" is a loaded term.

My list would be:

1. Code must work.
2. Code must be clear.
3. Code must be clear.

 
Ranch Hand
Posts: 145
2
Mac Java
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's very similar to writing. My current work involves a fair amount of writing and one of the organisations guidelines is that written work should follow the ABC:

A = Accurate.
B = Brief.
C= Clear.

I try to follow this rule when writing programs too. It seems to fit with the above. Good-o!

(I don't always succeed...)
 
Ranch Hand
Posts: 1408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote: I wanted to like Scala, really I did. But what I found off-putting was the community attitude of applying shortcut after shortcut to find the least amount of characters to express a statement. At that point, it's complete gobble-dee-gook to all but the Scala veterans. Cleverness trumps clarity. And I felt that newbies are sneered at. Others may have had a different impression, but that's what I felt and so gave up on Scala.

Sure you can write impenetrable code in any language*, but the impression I got from the Scala community is that (what I call) Obfuscation Through Brevity is an honored tradition. That is so not me.

I always hated use of the word "code" to describe computer programs. To me, the word "code" implies objuscation, as in "We encoded the message so the enemy can't read it."
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I've seen code that one would swear was encrypted.
 
Rancher
Posts: 352
21
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:The problem is with some people's definition of "simple".


How do you feel about Rich Hickey's definition of "simple" in his talk? He's fairly specific about what he means and the origin of that meaning, and why he advocates simplicity (over ease).

I think he's done a great job of guiding the evolution of Clojure with that goal of "simple" in mind, rather than being "easy". The syntax is simple -- there's very little of it. The core language is simple -- and based on a few (simple) abstractions like sequences. It isn't always easy to create simple software.
 
Ranch Hand
Posts: 789
Python C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Corfield wrote:
How do you feel about Rich Hickey's definition of "simple" in his talk? He's fairly specific about what he means and the origin of that meaning, and why he advocates simplicity (over ease).

I think he's done a great job of guiding the evolution of Clojure with that goal of "simple" in mind, rather than being "easy". The syntax is simple -- there's very little of it. The core language is simple -- and based on a few (simple) abstractions like sequences. It isn't always easy to create simple software.


He's taken a classical definition of complex and defined simple as its opposite. I think creating a new general-purpose language itself increases complexity! Too easy! But it's interesting to see somebody try to define and differentiate between simple and easy. It reminds me of Robert Pirsig trying to define quality.
 
Campbell Ritchie
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Corfield wrote: . . . and based on a few (simple) abstractions like sequences. . . .

Are they sequences? You access them with head and tail constructs. Surely that means they are stacks based on a singly‑linked list concept? It may make the language simpler but (as with some other functional languages), it requires deep recursion to handle long lists, which may cause slow execution or even exhaust the available stack space.
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Are they sequences? You access them with head and tail constructs. Surely that means they are stacks based on a singly‑linked list concept? It may make the language simpler but (as with some other functional languages), it requires deep recursion to handle long lists, which may cause slow execution or even exhaust the available stack space.


My understanding is that Clojure collections implement a common sequence interface i.e. that is the abstraction, but the various collections have their own performance characteristics: Clojure Data Structures - Collections. For example:

Vectors support access to items by index in log32N hops. count is O(1). conj puts the item at the end of the vector...


I think all the JVM FP languages have the same problem with recursion e.g. in Scala you use tail call optimisation, indicated via an annotation for compile-time checking, while Clojure has a separate loop-recur construct. Clunky in both cases, admittedly.
 
Campbell Ritchie
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chris webster wrote: . . . Clojure collections implement a common sequence interface i.e. that is the abstraction, but the various collections have their own performance characteristics . . .

Aaaaaaaaaaaah. Thank you.
 
Sean Corfield
Rancher
Posts: 352
21
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:it requires deep recursion to handle long lists, which may cause slow execution or even exhaust the available stack space.


You're more likely to process lists using higher order functions such as map, filter, reduce etc than using recursion, and those are "built-in" and highly optimized.

Also, as Chris noted, sequence is an abstraction in Clojure and intended to provide uniformity of processing: it doesn't imply an implementation (and in particular it doesn't imply a singly-linked list). You can write (first coll) and (rest coll) on any sequence and you can indeed write recursive functions if you wish, but it's fairly rare that you need to, given all the built-in higher order stuff (and loop / recur). In addition to the high performance vectors Chris mentioned, Clojure also has lazy sequences, chunked sequences, hash maps and sets, as well as being able to leverage any Java collection class (and still use the sequence abstraction over the top of it). You can even take an iterator and treat it as a sequence (although iterators are inherently stateful so some care is needed... since, you know... side effects are bad )
 
Campbell Ritchie
Marshal
Posts: 67454
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank yoiu.

I was remembering Oz where “lists” seem to be implemented as singly‑linked lists and you go into quadratic time very easily.
 
Sean Corfield
Rancher
Posts: 352
21
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I was remembering Oz where “lists” seem to be implemented as singly‑linked lists and you go into quadratic time very easily.


I think a lot of people imagine that sort of thing whenever a Lisp is mentioned. It was certainly true of the Lisps I worked with back in the 80's

One of the truly nice things about Clojure is that it's both simple and (mostly) very efficient so it's extremely practical to write large, complex systems with it and still have simple, maintainable code. We have about 25KLOC in production right now with approaching 9KLOC of test code (both unit tests and web driver tests) as part of a larger set of web apps in other JVM languages, and we love working on the Clojure portion -- in any other language, that would be 50-100KLOC (some people claim a factor of 10 compared to Java).
 
Guillermo Ishi
Ranch Hand
Posts: 789
Python C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One key to its success might be that you have to write enough lines of code that the result is both simple and easy...
 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Guillermo Ishi wrote:One key to its success might be that you have to write enough lines of code that the result is both simple and easy...


Yeah. Like we did for J2EE and EJBs...
 
Whatever. Here's a tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!