4 ms·
> Beginners have to be nurtured through lots of context that builds up slowly. My son is 17 and very interested in programming. Had to explain to him public,
by marklubi 1y ago
> Beginners have to be nurtured through lots of context that builds up slowly.
My son is 17 and very interested in programming. Had to explain to him public, private, internal, and also static the other night.
I then joked, you should ask your teacher about recursion tomorrow. He's with his mom this weekend, but I'm anxiously awaiting hearing how that went.
- devjab 1y ago> Had to explain to him public, private, internal, and also static the other night. Access modifiers are sort of a dying breed in a lot of places aren't they? We use Go, so we're obviously still using the two it comes with, but it's public vs module only and fairly intuitive. Every other language we have in production, doesn't make use of access modifiers. Similarily while static is a thing in Python, it's hard to see what advantages it brings compared to a free function if you're using a programming language that doesn't require you to have object instances to call non-static functions. Obviously access modifiers will stick around in a lot of organisations, but there will be plenty of jobs where you never have to work with them. The way Go handles modules, is frankly one of the few language feature of any language I've ever worked with that I wish was in every language I work with. It's so easy to use and so hard to mess up. Ok, I guess it's not hard to mess it up, but it's not intuitive.
- marklubi 1y agoNot going to disagree. It's the sandbox that we're playing in though (dealing with, HOORAY JAVA!) since it's a class at school. Have to start somewhere, teach them better alternatives as they evolve. Not even going to broach the prototype-based programing stuff until he comfortably has the basics understood. Edit: I don't GAF about downvotes, but I would at least expect a response about why. If you don't like the philosophy, give me some reasons. Don't like something else, tell me why. I'll happily debate anyone all day long
- mike_hearn 1y agoAccess modifiers are useful, albeit not for beginners. They're most useful in statically typed languages with good tooling where they keep auto-generated API docs and autocompletions clean. Static methods are useful for namespacing, e.g. var instance = SomeThing.fromString("...") In some languages you can of course make a global free function called someThingFromString which does the same thing, but then (a) it won't have access to private methods so the public API surface gets more polluted with stuff the user maybe shouldn't call themselves, and (b) it won't show up in the right place in generated API docs and (c) it won't show up in the expected place in type autocompletion. Kotlin has both static methods (or rather companion objects which are an equivalent), and also top level free functions, and when writing it I find myself creating static methods a lot more often for the above reasons.
- devjab 1y agoI probably shouldn't have worded it quite the way I did. Considering I praise Go's access modifiers. What I meant was the "old" way of having lots of them and explicitly having to write them out. I haven't tried Kotlin but it sounds nice. What I like about Go is the simplicity. Everything inside a folder is a package/module and any method beginning with a capital letter is public while every method starting with a lowercase name is package/module only. Coming from a decade of C# it was such a nice thing. I do work with a lot of Python where you don't have private methods. I mean, you can set up your corporate environment to "hide" _methods or whatever, but they are never turly private, and static methods are... well... they are basically just namedspaced top level functions.
- 1718627440 1y agoPython does name-mangling of private (__foo) methods.
- 1718627440 1y agoPython has public/protected/private as well as static/class/instance methods. > doesn't require you to have object instances to call non-static functions Not sure, what you mean, because you need to pass something for self? Either: obj.foo (args...); Or: cls.foo (obj, args...);
- bckr 1y agoHe’s starting with Java? I wonder if that’s the right language to start with. What is he most interested in doing? Anyway thanks for nurturing the next generation.
- marklubi 1y agoI fully disagree with Java as a starting point and it was an interesting conversation with the teacher. Apparently, "College Prep" courses more or less determine that Java is the language that they should use. His teacher thought it was stupid as well, but sometimes your hands are tied. That's what the schools are using as a starting metric though. He was apparently the only person in the class that said he wanted to do software engineering. Don't worry, he'll be a polyglot before he reaches college.
- sfn42 1y agoI learned Java in uni and think it's a fine language to start with. It's also been modernized a lot in the past decade, and if you really want a more modern language it's easy to transition to Kotlin. I'd take Java over Python or JS any day. It wins on performance, it wins on type system, js is just a plain trash language not at all suited for general purpose programming (TS solves some problems but not all and it has its own problems) and python is fineish but it's slow and just kind of icky, I'd never do serious software development in python. It's fine for small scripts and notebooks and such, we learned python as part of our math classes while the programming classes focused primarily on Java. We also had a class on web development using JS, ML using Python and windows programming using C++ and C#. I struggle to see any significantly better candidates for a first language than Java. Sure you could go with C but nobody really uses it any more outside of niches. C++ is out, too much stuff. I really like C#, it's my daily driver and I wouldn't mind it as a first language but I think Java is more approachable for beginners. Less confusing syntax to learn. I don't know Go but maybe that could be an alternative? Other than that I'm a bit out of options. Java is a fairly simple language that's easy to learn and allows teaching a lot of important concepts that will be useful in other languages moving forward. That's a big thing I think, it's not meant to be the only language. The word polyglot is used some times, to me it just means programmer. I don't know any competent developers who only know one language. You end up learning multiple and I think Java is a good entry point.
- JohnKemeny 1y agoI think Java is dying. If you want to teach algorithmic thinking, teach Python. If you want to teach hardware and low-level systems, teach C.
- mike_hearn 1y agoJava doesn't have an internal modifier. Concepts like public, private and static exist in Python too.
- marklubi 1y agoI concur with most of your thoughts, except that Java is never going away. I might wish that it would, but here we are.
- throwaway2037 1y ago> I think Java is dying. There are millions of enterprise programmers around the world that use it. If it is dying, then what is replacing it in the enterprise? From my perspective, I don't see any serious competition. At the moment, I see this pattern for mega enterprise: * C++ for scientific, mathematical, financial core libraries * Java for heavyweight backend services that run on Linux * DotNET for thick clients that run on Windows desktops/laptops * NodeJS for lightweight backend services that run on Linux * HTML/CSS/JavaScript (plus frameworkds) for lightweight web apps * Python for data analysis and AI/ML work
- sfn42 1y agoSome notes: .NET can serve the same use cases as Java, it's not just for windows programming. It's actually getting really good. NodeJS does nothing better than anyone. The only things I can think of that make node worth using is electron and react native, maybe Next but I'd much rather do SSR in a real programming language personally. I would never use node as a pure backend, there's just no reason to and JS is an F tier language. TS brings it up to like C but it's still just not good enough to compete. I can't see any reason to choose node for typical backend programming and such unless your devs only know JS. Any other language is probably better suited.
- pyjamafish 1y agoAh, the infamous public static void main(String[] args). Hopefully the next generation won’t need to learn all those concepts up front with the introduction of instance main methods in Java 25. https://openjdk.org/jeps/512 https://openjdk.org/jeps/512
- mrguyorama 1y agoI actually think the inscrutable Main method in java has some value. As a kid, I loved to know how things worked and always did things like read instruction manuals and read ahead in school textbooks. I wanted to know everything about anything, and I wanted to know how it worked from the bottom up. The java main method taught me "This is abstraction, an important concept in programming. You won't always know how all the magic works all the time" It taught that you have to deal with black boxes. Also, I never saw it cause problems in CS101 classes, because the kids curious enough to want to know something their professor didn't explicitly talk about were usually the ones who would do fine at learning all the parts of it. The kids who struggle with programming never seemed to have problems following "Just write your code here, you will learn more about it later"
- philipwhiuk 1y agoMaybe he and his teacher are caught in a loop ;)