10 ms·
Ada 95: The Craft of Object-Oriented Programming
- pyjarrett 3y agoMy favorite thing about Ada is how it uses modules ("packages") for encapsulation and not classes. This separates it from a lot of other languages with object-oriented programming by allowing you to split up and expose externally visible behavior in modules and submodules without making type internals visible, but allowing other elements in the implementation side of the module and submodules to look inside.
- akritid 3y agoThe explicitly specialised generic packages are nice too
- ReleaseCandidat 3y agoYes, they are "officially" ML (no, not that ML) style. https://ada-lang.io/docs/learn/why-ada#feature-overview https://ada-lang.io/docs/learn/why-ada#feature-overview
- pjmlp 3y agoMost languages with OOP also do modules, all the way back Simula and Smalltalk started to influence Mesa/Modula-2 derived languages. Additionally in a somewhat naive ways, classes can be seen as extensible modules, which in the presence of generics is less required as in languages that don't support them. When using something like Standard ML functors, classes aren't really needed.
- com2kid 3y agoI don't know why integer derived types don't exist in every language, from what I understand they are a compile time feature that removes large swaths of potential errors. We all agree that string enums are generally a good idea when we want to limit passed in configuration values to a limited set of valid strings, so why not ensure that if 2 (or 5...) integers are passed into a constructor (looking at you Java) that they are actually all of the proper "type" of integer? For those who don't know what I am talking about, Ada lets you do stuff like (taken from the linked book) type Age is new Natural range 0..150; and now you can say that the age parameter on a function is of type Age, and if you try to pass some other integer type in, it will fail. Ada's type system is so powerful that the metric system of measurements, with physics units, speed, acceleration, all that jazz, can be expressed in it. I've seen C++ people say "but templates can do that!" but if I ask about how much eye bleed is included, they always change the topic...
- teaearlgraycold 3y agoIt doesn’t compare, but TypeScript can do this for small ranges, or small sets, very well.
- throwaway13337 3y agoAgreed! Expanded type guards can replace a huge amount of unit tests in a way that is more concise and provides a better promise to more of the code. It's about orientation. Orienting around the data makes so much more sense. Why test every function's email address param when you can instead guard via an email address type? Typescript is the most popular language to try and their type system is a lot of fun. However, the compiler messages remind me of working with Boost libs in C++. It's also unfortunate that typescript actually provides no guarantee about runtime so I never have complete confidence like I do with real static typed languages. You can also get to a point in typescript where you go down a type system rabbit hole and find yourself a code philosopher. It's been a personal black hole for time wasting on a project for me. Libs like Zod go a long way in JS and they accomplish the same but better for me. They leverage typescript and you get compile time and runtime support. Vogan in C# provides compile time warnings but uses generated code to achieve it. It is impressive what the new code generation support in C# can do now. Still, it would be nice to have first class support from a language. https://github.com/colinhacks/zod https://github.com/colinhacks/zod https://github.com/SteveDunn/Vogen https://github.com/SteveDunn/Vogen
- mbStavola 3y agoRust is considering this under the name of "pattern types" [0][1]. If the full idea is realized, you should be able to handle strings and enums as well. There is also a PR for a minimal implementation using a macro and targeting integers specifically[2]. It's experimental and there is a chance this doesn't get stabilized, but here's hoping it makes it through! [0]: https://github.com/rust-lang/rust/pull/107606 https://github.com/rust-lang/rust/pull/107606 [1]: https://cohost.org/oli-obk/post/165584-ranged-integers-via https://cohost.org/oli-obk/post/165584-ranged-integers-via [2]: https://github.com/rust-lang/rust/pull/120131 https://github.com/rust-lang/rust/pull/120131
- 3y ago
- jeff-davis 3y agoIt looks like Ada 2022 has a way to track at compile time whether functions block or not. Seems cool for async programming. http://www.ada-auth.org/standards/22over/html/Ov22-2-2.html http://www.ada-auth.org/standards/22over/html/Ov22-2-2.html
- synack 3y agoI don't think any compiler implements that yet.
- jeff-davis 3y agoDo you believe it was designed and standardized as a reasonably implementable feature?
- synack 3y agoI'm far from an expert on compiler development, but I think it's just a matter of walking the AST to ensure that there aren't any calls to procedures with the Global or Nonblocking aspects inside a parallel block. The bigger issue is that the `parallel do` and `parallel for` blocks added in Ada 2022 [1] haven't been implemented and as far as I know, nobody's working on it. I suspect that if we ever do get parallel support, it'll come from the GNAT-LLVM project [2], rather than GNAT-GCC. In the meantime, there's a CUDA compiler [3]. [1] http://www.ada-auth.org/standards/22over/Ada2022-Overview.pdf http://www.ada-auth.org/standards/22over/Ada2022-Overview.pd... [2] https://github.com/AdaCore/gnat-llvm https://github.com/AdaCore/gnat-llvm [3] https://github.com/AdaCore/cuda https://github.com/AdaCore/cuda
- pjmlp 3y agoOnly recently have compilers started catching up to Ada 2012 and SPARK, outside Ada Core, thus this will take a while.
- mikeflynn 3y agoAda 95 was the first language taught in my college CompSci program back in 1999 (this might have even been my textbook). Everyone would complain about Ada because no one had heard of it before, but looking back it was the right call. A great language to learn the basics on and not get in to trouble. They’ve since moved to Java and now probably something else.
- yawaramin 3y agoI'm guessing Python.