Jump to content
  • Advertisement
Sign in to follow this  
Kreative

Concept of abstraction in programming

This topic is 958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I wonder does anyone else here wonder about how insanely powerful abstraction is and how it works, how it can be improved? The topic focuses on much more on than just a modifier like abstract from java that can be applied to methods or its brother virtual in C++. Is it a good idea to view the common concept of abstraction in programming as revolving around run-time re-evaluation, or re-execution so as to be able to output an ever-different value from the program's ever-altering state. This leads me to consider that functions are kind of abstract because they are the sum of their operations mainly, and the hard-coded bits such as primitive data typed in by the programmer to be applied to the output of the function. Being a sum of operations rather than a one time evaluated result since the inputs can always vary, which leads to a different output, is a form of abstraction, true? Couldn't one consider the concept of pointers or references as abstract, since they constantly reflect on their reference object every time they are used / called, which mirrors the essence of being the sum of its operations, since it always re-evaluates upon use. Classes can be considered abstract and are better seen so in prototype-based languages since they are templates with non-implemented identifiers or functions which always vary during run-time as instances.

 

Anyone else think about this, are some of my assumptions incorrect? I find this topic insanely confusing because when it comes down to the definition of abstract, it literally means something like conceptual, or not full, which contradicts the practice of implementing ideas into reality for better understanding. Anyone know any programming languages that explore this concept in a very interesting way? I am exploring this idea in an attempt to understanding programming languages and how they could be improved, re-wamped. Just... abstraction...

Kind Regards,
Kreative

Edited by Kreative

Share this post


Link to post
Share on other sites
Advertisement
So, like, this is pretty much Computational Science 101... tongue.png

Languages that predate C (e.g. LISP) may be what you're looking for. Or any of the other higher-order functional languages, which are of course all about the mathematical abstractions of computation rather than driving the Turing-style hardware we use today.

Share this post


Link to post
Share on other sites

Abstraction takes on many different meanings in the programming world. I also second that you should probably explore the functional space as well.

 

If you want to really explore mathematical abstraction the place to start is Haskell combined with Category Theory. I mention these two together because Haskell is the embodiment of Category Theory in a programming language.

 

Haskell will mess with your mind until you start to grok it and then you will find a purity and beauty and way of thinking and expressing yourself that is missing from most other languages.

Share this post


Link to post
Share on other sites

At the moment Scala is a very "naughty" language that tries to push the limits of the JVM. I have mixed feelings about it, but it's a real mind bender.

 

PROLOG is one of the most abstract languages I've ever used. It's quite old, but basically what you write is very loosely coupled with what actually runs. It is way more abstract than any notion of classes and pointers... Even the order of the commands (the instruction register?) is decoupled from how you write your code. Although it is not heavily used in the industry, it is very well studied in Academia. If you want to experience highly abstract code, try some  Prolog.

 

I've also heard interesting things about ERLANG. (never used it).

Share this post


Link to post
Share on other sites

It very strongly feels like that the more flexible, meta-flexible and abstract flexible a programming language is, the more powerful it is, like from my somewhat inexperienced understanding, object-oriented programming is, at the deepest end, born from abstraction.

Is it safe to view functions as abstract? Since they are in-complete, not concrete bodies which operate upon receiving input.

Is it safe to view classes as abstract? Since they are in-complete, are non-concrete templates for constructing.
Is it safe to find pointers relevant to abstraction? Since they have no value within themselves, just reference it.

@SillyCow I was actually once very interested in Scala, because I believed, as I still do, that java is very limited in the sense that it doesn't allow class members that are shared across every instance yet also part of the inheritance tree, some suggested that Delphi allows something like this, and is called class-types or alike.

A simple embedded language like Lua seems impossibly powerful to me just because it implements a simple function called setmetatable, I've seen discussion titles on google of how it allows you to make your own object-orientation and the idea that you can create from even deeper than within a pre-defined OO environment justifies this to me.

I have looked a few times at programming languages like Haskell and Lisp, and I find them incredibly amazing, and I just don't understand why don't people use them? Ultimate flexibility, minute or no repetition and efficiency from highest priority to lowest, are what I consider possibly the most important aspects of a programming language and, it may be just me but, I see major programming languages like Java just fail to achieve them in some situations horribly.

Kind Regards,
Kreative

Share this post


Link to post
Share on other sites


I find this topic insanely confusing because when it comes down to the definition of abstract, it literally means something like conceptual, or not full, which contradicts the practice of implementing ideas into reality for better understanding. Anyone know any programming languages that explore this concept in a very interesting way? I am exploring this idea in an attempt to understanding programming languages and how they could be improved, re-wamped. Just... abstraction...

 

Computers are abstractions all the way down.

 

Nearly any time we (as humans) can abstract processes away under a simple description, we (as humans) are more productive. 

 


Being a sum of operations rather than a one time evaluated result since the inputs can always vary, which leads to a different output, is a form of abstraction, true? Couldn't one consider the concept of pointers or references as abstract, since they constantly reflect on their reference object every time they are used / called, which mirrors the essence of being the sum of its operations, since it always re-evaluates upon use. Classes can be considered abstract and are better seen so in prototype-based languages since they are templates with non-implemented identifiers or functions which always vary during run-time as instances.

 

Simple example:  the abstraction we use "Open a web page to {site}."  That is an abstraction that most computer-savvy people are comfortable with.

 

In the late 90s that meant giving people exact instructions on going to their computer, finding and opening a web browser, going to the location bar on the browser, and typing in "H T T P, colon, yes that is the two dots, slash, slash, that is the one leaning to the right with the question mark key, w, w, w, dot, that means the period button, ...."

 

For computers, opening a web page is an abstraction for parsing a URI to get the host and the message, opening a connection, sending the request, interpreting the response, repeating the process for all the resources like images and style sheets, then composing the results into a nice pretty pictures.

 

Each one of those are abstractions, opening a connection to the host is an abstraction for the system looking up DNS entries, which itself starts with an abstracted-away process of the systems' DNS cache then finding the results, that cache is an abstraction away from some actual data structures, which are an abstraction away from the system's virtual memory, which is an abstraction away from the hardware's actual memory, which is an abstraction away from the system's components, which is an abstraction away from the actual chips, which is an abstraction away from the circuits.... etc.

 

 

We use abstractions all the time. As game developers we need to be careful of our abstractions because many have hidden costs. But thinking in abstractions is very useful. 

 

When you are implementing new features and systems, thinking in abstractions enables powerful transformations and lets you figure out communications patterns fairly easily. The game objects get added to the game world and then all communications go through that channel.  Adding to the game world means a process to get added into spatial trees, get hooked up for collision detection and collision response and pathfinding and registering for events, etc.

 

 

Then we have abstractions for all our libraries.

 

Commands to open a file are abstract, it does whatever magic it needs to get the disk caches working, to open files if they are on the local hard drive or USB drive or optical disc or even somewhere on the network, or even back in the day prompting the user "Insert diskette into drive A:" or a process to load a tape cassette.  Then it magically buffers data and does a bunch of other work that I don't keep track of. 

 

Abstractions are what enable us to build complex software, and to stand on the shoulders of the giants who came before building those systems.  

 

Get comfortable working with abstractions, they're a good thing.

Share this post


Link to post
Share on other sites

It very strongly feels like that the more flexible, meta-flexible and abstract flexible a programming language is, the more powerful it is, like from my somewhat inexperienced understanding, object-oriented programming is, at the deepest end, born from abstraction.

 

 

All programming is abstraction, all the way down to registers in assembly language, where we believe the world is digital, but it really isn't smile.png

 

 

However, I don't agree that more flexibility means more power. It depends a lot on how you define those concepts. To explain let's compare Lua with Java.

 

Lua is incredibly small, it is designed and implemented by a bunch of language researchers. I fully agree it's very flexible. I think it's a great tool if you want to do language research. You have a small simple language, you can implement your own form of classes in it, and do experiments. If you want to change something, it's relatively easy, as Lua is very small in implementation as well.

 

Java on the other hand, is a big rock in every way. It library has several thousand classes. It's not very flexible, you get what the manual says, and that's it. No tuning or custom extending to ease programming. It does however know how to handle a big code base. In fact, it's famous for being used in such projects. The reason is simply (I think), Java is the right tool for the job. If you have a couple of hundred developers working on something for a few years, you need something rock-solid to work in. You may hate the language (I do too somewhat for its sillynesses), but it's a workhorse for big projects, and it does the job.

 

Trying to use Java where Lua shines, or Lua where Java shines doesn't work. As such, I think both Lua and Java are powerful, but each in its own way.

 

 

 

Is it safe to view functions as abstract? Since they are in-complete, not concrete bodies which operate upon receiving input. ...

"abstract" has that meaning in programming languages (that is, "abstract" means "not really there"). Commonly, abstract means "only considering a part" https://en.wikipedia.org/wiki/Abstraction_%28disambiguation%29   ie, you ignore some parts of the whole, whether or not the parts actually exists. The latter form is thus wider than your notion of abstract.

 

 

But to answer your question, yes it is safe. The point is that at the abstract level you have no intention of using the parts you ignore. If you would, your abstraction is wrong. You would not work at the abstract level where existence of the part is irrelevant, but instead at the detail level, where you worry about existence of all bits, proper names for everything, etc etc.

 

 

This is also what stops you from going very very abstract with anything concrete that you want to make. In the end, all the pieces have to be there, and they all have to fit together. If they don't, it is not going to work. You can add abstraction layers all you want, but the more layers you add, the more work you get to realize everything down to the last bit.

 

 

If you never go down to the concrete level, things are easier and you can basically go up to any abstraction level you can imagine without problem. Science does that a lot, writing loads of papers about abstract properties of abstract things. But imho this is much like Lua versus Java. Both concrete and abstract are powerful, but in their own way.

Share this post


Link to post
Share on other sites


The topic focuses on much more on than just a modifier like abstract from java that can be applied to methods or its brother virtual in C++.

Indeed, too much focus is paid to such things. It is not unusual for an "abstract class" or "pure virtual class" to offer little actual abstraction.

 


PROLOG is one of the most abstract languages I've ever used. It's quite old, but basically what you write is very loosely coupled with what actually runs. It is way more abstract than any notion of classes and pointers... Even the order of the commands (the instruction register?) is decoupled from how you write your code. Although it is not heavily used in the industry, it is very well studied in Academia. If you want to experience highly abstract code, try some  Prolog.

This sounds more like the distinction between declarative and imperative programming, and / or the difference between high and low level languages. You can still write very "concrete" (non-abstract) Prolog programs, even if the execution engine has a lot of flexibility in how it might evaluate said program.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!