News for hackers. Stuff that matters.
Re:Has UML died without anyone noticing? by cratermoon on Sunday April 25, 2021 @06:14PM (#26937230)
Ward Cunningham once noted that because a programmer can input incomplete, or minimal, code, then push a few buttons to autogenerate the rest, that there's a smaller language inside Java. Since he made that remark a number of other JVM languages have sprung up that try to be less verbose. One of them is Groovy, which uses type inference and other semantics to reduce duplication (or "stuttering" as Go calls it").

The issue now with Java is that it's such a big language and it's accumulated so much from many different paradigms that experience in "Java" doesn't always transfer across different companies or teams. Some teams hew closely to OO design and patterns, others use a lot of annotations and dependency injection, still others have gone fully functional since Java 8.

And then there are shops like one of my employers, where a large codebase and poor teamwork has resulted in a mishmash of all of the above, plus some sections that have no organizing principles at all.

Re:Has UML died without anyone noticing? by DaiPlusPlus on Sunday April 25, 2021 @07:20PM (#26937661)
> Some teams hew closely to OO design and patterns

I maintain that design-patterns are just well-established workarounds for limitations baked into the language - and we get used to them so easily that we rarely question why we’ve even built-up an entire mechanism for programming on-top of a programming language that we never improve the underlying language to render those design-patterns obsolete. (I guess the language vendors are in cahoots with Addison-Wesley...)

For example, we wouldn’t need the Visitor Pattern if a language supported dynamic double-dispatch. We wouldn’t need the adapter, facade, or decorator patterns if a language supported structural typing and/or interface forwarding. We wouldn’t even need to ever use inheritance as a concept if languages separated interface from implementation, and so on.

Better answer: the only real OOP system is Smalltalk.

Re:Has UML died without anyone noticing? by cratermoon on Sunday April 25, 2021 @07:35PM (#26937771)
> design-patterns are just well-established workarounds for limitations baked into the language

Strict functional programmers have been saying that for years. They may be workarounds, but as patterns they have value in allowing one programmer to structure code in a way that is recognizable to another, even months later. You could say that a steering wheel, gas pedal, and brakes are workarounds for limitations baked into the automobile we wouldn't need if cars could drive themselves, but still value the fact that the steering wheel and the rest of the controls for a driver generally look and work the same across vehicles.

Re:Has UML died without anyone noticing? by DaiPlusPlus on Sunday April 25, 2021 @07:55PM (#26937895)
Right you are - but my point is that language designers (especially Java’s) aren’t evolving their languages to render the more tedious design-patterns obsolete - instead they seem to accept the DPs are here to stay.

Take the singleton pattern for example. It’s not perfect: it only works when constructors can be marked as private and/or when reflection can’t be used to invoke the constructor to create a runtime-legal second instance. A better long-term solution is to have the language itself natively support passing a reference to static-state, which completely eliminates the risk of a private ctor invocation - but that hasn’t happened.

OOP Design Patterns are like JavaScript polyfills: they enable things that should be part of the native platform. They’re fine to keep around for a few years when they’re new, but when you’re still using what is essentially an aftermarket add-on for 5+, 10+ or even 25+ years you need to ask if it’s the way things should be or not...

Re:Has UML died without anyone noticing? by piva00 on Sunday April 25, 2021 @07:49PM (#26937860)
Patterns are commonly (but not only) symptoms of some failure of features on the language but at the same time they are just vocabulary.

Patterns exist in functional programming as well, any map/reduce operation is a pattern, any monad is a pattern. It's a proven way to achieve a goal, it's easy to compartmentalise under a moniker and refer to the whole repeatable chunk with a name.

Unfortunately a lot of people only learn how to properly apply design patterns after doing it wrong and/or overdoing it (mea culpa here!). It's easy to spot the bad smells after you've been burnt 2-3 times.

Re:Has UML died without anyone noticing? by closeparen on Sunday April 25, 2021 @11:23PM (#26938942)
If map and reduce were design patterns, you’d be writing out the iteration bits every time you used them. Instead map and reduce are abstractions, and you only have to plug in your unique functions and values.
Re:Has UML died without anyone noticing? by juki on Monday April 26, 2021 @12:17AM (#26939212)
piva00 probably meant that implementing map and reduce for a data structure, rather than the use of them, is a design pattern.
Re:Has UML died without anyone noticing? by piva00 on Monday April 26, 2021 @03:27AM (#26940160)
That was my point, thanks for clarifying it :)
Re:Has UML died without anyone noticing? by mgarus on Tuesday April 27, 2021 @08:20AM (#26954895)
This reminds me of a talk by Rich Hickey [0], where he introduces the Transducer pattern, which is actually an abstraction for map/reduce/fold/filter etc.

(But I'm not trying to invalidate your claim that patterns exist in FP in general, only that specific case. Afaik, the Transducer abstraction isn't even widely-known nor used.)

[0]: https://www.youtube.com/watch?v=6mTbuzafcII

Re:Has UML died without anyone noticing? by smiga_ on Monday April 26, 2021 @04:16AM (#26940413)
What resources would you recommend for learning more about design patterns that are essentially missing language features?
Re:Has UML died without anyone noticing? by DaiPlusPlus on Monday April 26, 2021 @09:10AM (#26942131)
By writing enough code using design-patterns that you see a pattern to the usage (and abusage) of design-patterns - and get plenty of experience with other languages and paradigms where said patterns are irrelevant.
Re:Has UML died without anyone noticing? by cratermoon on Monday April 26, 2021 @09:36PM (#26950755)
Re:Has UML died without anyone noticing? by piva00 on Sunday April 25, 2021 @07:42PM (#26937819)
I'd agree with that statement. I feel that I have settled in a few frameworks that I consider modern but mature and stable, with a good job market. For that I had to learn these smaller languages inside Java.

And not only smaller languages, the tool set as well. Maven and Gradle for a start, and Gradle is its own Universe of little quirks and "what the fuck" moments. IDEs have a learning curve (but I learned vim and emacs before using any IDE so knew how steep learning curves work) and if you manage to use their features it can help immensely your productivity. Frameworks such as Spring have enough pull that it's easy to find interesting projects with it, I think that the direction of Spring Boot is pretty good for modern tech enterprises, at least for part of the stack.

Boring technology has its place, it's a hassle you have to learn a pretty big set of tools to be productive in Java but when you do you can actually accomplish a lot with multiple teams and a scale of hundreds to thousands of engineers.

You can also shoot yourself on the foot pretty easily, in massive scale, if the people taking decisions are architecture astronauts and not battle-hardened engineers who have suffered through incomprehensible code and piles over piles of mishmash of technologies and failed frameworks. Keeping the tech stack simple, boring and focused on a small set of tools has its benefits on scale.

Re:Has UML died without anyone noticing? by xwolfi on Sunday April 25, 2021 @07:21PM (#26937667)
Groovy is a nightmare. We now reject candidates who advocate for it in production during interviews and we warn those who do say they d never dare there but use for testing.

Who cares if you have to write setters and getters by clicking a button in IntelliJ, or have to explicit your types rather than ask every subsequent readers to use their brain as a type inference compiler.

Typing clear code isn't a problem Groovy should have solved by making it all implicit, at the cost of having non compiled production code. A code should never fail at runtime because you made a function name typo that it couldnt tell you about any other time for free.

Re:Has UML died without anyone noticing? by signal11 on Sunday April 25, 2021 @08:12PM (#26938012)
A lot of this also applies to other interpreted languages widely used in production, such as Ruby, Python and Clojure.

You don’t like interpreted languages in production, fine. But rejecting candidates who think differently from you just creates a monoculture and reduces the chance that you learn anything new, beyond reinforcing your own convictions.

Re:Has UML died without anyone noticing? by jnwatson on Sunday April 25, 2021 @11:48PM (#26939076)
Millions of lines of production Python code do just fine by doing the thing you should have been doing all along: testing.
Re:Has UML died without anyone noticing? by closeparen on Sunday April 25, 2021 @11:38PM (#26939018)
How rational this is depends on your testing culture. With a comprehensive test suite, the guarantees offered by a compiler are not very important. The software goes through all its runtime paces before production anyway.

If you’re not going to write any tests, then obviously compile time is a crucial line of defense.

Most shops will be somewhere in the middle where compiler guarantees offer a real but marginal benefit, to be weighed against other tradeoffs.

Re:Has UML died without anyone noticing? by zozbot234 on Monday April 26, 2021 @05:17AM (#26940707)
The point is not "let's just not write any tests". With a compiler that offers meaningful guarantees, you can write more worthwhile tests than "does this function always take/return integers".
Re:Has UML died without anyone noticing? by closeparen on Monday April 26, 2021 @12:04PM (#26944092)
If you’re passing or returning values of the wrong type, it’s going to blow up one of your tests. Asserting on a value implicitly asserts its type. Passing a value and not getting a runtime error for your trouble, pretty strongly indicates that it’s the right type.
Re:Has UML died without anyone noticing? by corty on Monday April 26, 2021 @04:37AM (#26940519)
Writing tests instead of utilizing the compiler is wasted time and effort. And it is one of the worst kinds of code duplication, because you are reimplementing all the type-checking, bounds-checking, etc. Usually badly, buggy and again and again. And since usually the test suite doesn't have tests for the tests, you will only notice if something breaks in the most inopportune occasion possible.
Re:Has UML died without anyone noticing? by jnwatson on Monday April 26, 2021 @10:54AM (#26943136)
In unit testing for dynamically typed languages, very rarely do you make explicit type checks. The type checking naturally falls out of testing for correct behavior.

The "tests for the tests" is code coverage.

Re:Has UML died without anyone noticing? by cratermoon on Sunday April 25, 2021 @07:40PM (#26937807)
> A code should never fail at runtime because you made a function name typo that it couldnt tell you about any other time for free.

So you also reject all dynamic and weakly typed languages? No JavaScript, Objective-C, PHP, Python, Ruby, Lisp, or Tcl? No type coercion at runtime?

> at the cost of having non compiled production code

Groovy can be compiled to the same bytecode as Java.

Re:Has UML died without anyone noticing? by kazinator on Sunday April 25, 2021 @09:32PM (#26938400)
If the language doesn't help you with a function name typo, that's crap dynamic. Not only is that not a feature or benefit of dynamic, but it fuels unfair strawman arguments against dynamic.

Here is something I made largely for my own use:

  This is the TXR Lisp interactive listener of TXR 257.
  Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
  TXR is enteric coated to release over 24 hours of lasting relief.
  1> (file-put-string "test.tl" "(foo (cons a))")
  t
  2> (compile-file "test.tl")
  * test.tl:1: warning: cons: too few arguments: needs 2, given 1
  * test.tl:1: warning: unbound variable a
  * test.tl:1: warning: unbound function foo
  * expr-2:1: variable a is not defined
That's still a strawman; it only scratches the surface of what can be diagnosed.
Re:Has UML died without anyone noticing? by gher-shyu3i on Sunday April 25, 2021 @08:29PM (#26938107)
For any non-trival program (more than a couple of files/pages long), dynamic and weak typing are a no-go.
Re:Has UML died without anyone noticing? by cratermoon on Sunday April 25, 2021 @08:42PM (#26938164)
How strongly typed is C? Are non-trivial programs in C a no-go? Would a LISP program more than a couple of pages long be forbidden?
Re:Has UML died without anyone noticing? by gher-shyu3i on Sunday April 25, 2021 @08:47PM (#26938181)
There are toolings that patch C's shortcomings, and there's a reason better typed languages (e.g. Rust) are making strides in C's domain.
Re:Has UML died without anyone noticing? by jjgreen on Monday April 26, 2021 @04:11AM (#26940396)
TIOBE gives C 14.32% (1) against Rust 0.49% (29), so "strides" might be over-egging the pudding.
Re:Has UML died without anyone noticing? by gher-shyu3i on Monday April 26, 2021 @10:49AM (#26943075)
Historic vs future trends.
Re:Has UML died without anyone noticing? by thrwaeasddsaf on Monday April 26, 2021 @05:58AM (#26940910)
Which tools patch C's shortcomings?
Re:Has UML died without anyone noticing? by gher-shyu3i on Monday April 26, 2021 @10:48AM (#26943068)
Static analysis tools and subsets like MISRA C.
Re:Has UML died without anyone noticing? by thrwaeasddsaf on Monday April 26, 2021 @12:21PM (#26944345)
Do you have a good one in mind? All the open source tools I've tried are MISRAble
Re:Has UML died without anyone noticing? by gher-shyu3i on Tuesday April 27, 2021 @06:13AM (#26954041)
Nope, I haven't been working with C recently.
Re:Has UML died without anyone noticing? by cataphract on Sunday April 25, 2021 @08:04PM (#26937960)
I see where you're coming from, having used Groovy for a few years (in Grails, mostly) but I think you're also overstating your case.

Groovy is very quirky, and it's good at turning compile errors into runtime errors (@CompileStatic negates many of its advantages like multiple dispatch) and making IDE refactoring less effective. But the again, so is Spring. This got better when Java configuration was introduced... and then came Spring Boot, which is a super leaky abstraction, with default configuration that automatically backs off depending on arbitrary conditions (!). And yet people find it valuable, because it reduces boilerplate.

These days, I use Groovy mostly in testing (and Gradle), and it can really make tests more expressive.