Tuesday, August 25, 2020

Digest for comp.lang.c++@googlegroups.com - 12 updates in 3 topics

"Christian Hanné" <the.hanne@gmail.com>: Aug 25 06:38PM +0200

Is there any CPU-architecture with CPU-instructions to support
object protection-levels like private, protected, publich (and
package in Java)?
I think that would be very cool since you could establish security
-mechanisms on top of that.
"Christian Hanné" <the.hanne@gmail.com>: Aug 25 07:07PM +0200

Am 25.08.2020 um 18:38 schrieb Christian Hanné:
> package in Java)?
> I think that would be very cool since you could establish security
> -mechanisms on top of that.
 
Imagine that the methods are dynamically dispatched according to their
signature-hash through special CPU-instructions. That would be rather
fast and you could have dispatching-mechanism for component-based soft-
ware with security-checking.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Aug 25 07:14PM +0200

On 25.08.2020 19:07, Christian Hanné wrote:
> signature-hash through special CPU-instructions. That would be rather
> fast and you could have dispatching-mechanism for component-based soft-
> ware with security-checking.
 
As I recall IBM has at least one mainframe with hardware Java support.
 
Wikipedia lists, at <url: https://en.wikipedia.org/wiki/Java_processor>:
 
"
• picoJava was the first attempt by Sun Microsystems to build a Java
processor
• aJ102 and aJ200 from aJile Systems, Inc. Available on boards from
Systronix
• Cjip from Imsys Technologies. Available on boards and with wireless
radios from AVIDwireless
• Komodo is a multithreaded Java microcontroller for research on
real-time scheduling
• FemtoJava is a research project to build an application specific Java
processor
• ARM926EJ-S is an ARM processor able to run Java bytecode, this
technology being named Jazelle
• Java Optimized Processor for FPGAs. A PhD thesis is available
• SHAP bytecode processor from the TU Dresden
• <url:
https://www.sciencedirect.com/science/article/abs/pii/S0141933105000967?via%3Dihub>
provides hardware support for object-oriented functions
• ObjectCore is a multicore Java processor designed by Vivaja Technologies.
• Java Offload Engine (JOE) is a high performance Java co-processor from
Temple Computing Labs LLP.
"
 
Curiously the Wikipedia article doesn't mention the IBM machine or machines.
 
 
- Alf
Stefan Monnier <monnier@iro.umontreal.ca>: Aug 25 01:18PM -0400

> Is there any CPU-architecture with CPU-instructions to support
> object protection-levels like private, protected, publich (and
> package in Java)?
 
The details of what is allowed and what is not in languages offering
those kinds of "protection levels" tend to be ever so slightly different
in each language, so it would probably be hard to provide hardware that
can efficiently reflect faithfully all those slight variations.
 
Furthermore, AFAIK Java doesn't implement those checks at run-time but
at load-time instead (while typechecking the JVM byte-code), because it
would be costly to make those checks at run-time.
 
Maybe dedicated hardware could perform such checks more cheaply than the
JVM's runtime on stock hardware, but IIUC the cost doesn't come just
from a few extra instructions executed during the check but also from
the extra information that needs to be preserved, propagated, and
accessed in order to perform the checks, and dedicated hardware would
still have to pay that extra cost.
 
And the result would still be slower than performing those checks at load-time.
 
So I suspect that the market for such a thing is too small to justify
the investment.
 
 
Stefan
Jorgen Grahn <grahn+nntp@snipabacken.se>: Aug 25 06:39PM

["Followup-To:" header set to comp.lang.c++.]
 
On Tue, 2020-08-25, Christian Hanné wrote:
> Is there any CPU-architecture with CPU-instructions to support
> object protection-levels like private, protected, publich (and
> package in Java)?
 
That would be pointless, because private/protected/public are checked
at compile time.
 
> I think that would be very cool since you could establish security
> -mechanisms on top of that.
 
They aren't security mechanisms. (Not in C++ anyway.)
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Melzzzzz <Melzzzzz@zzzzz.com>: Aug 25 07:05PM

> package in Java)?
> I think that would be very cool since you could establish security
> -mechanisms on top of that.
 
OOP is out of fashion...
 
 
--
current job title: senior software engineer
skills: c++,c,rust,go,nim,haskell...
 
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Ivan Godard <ivan@millcomputing.com>: Aug 25 01:14PM -0700

On 8/25/2020 9:38 AM, Christian Hanné wrote:
> package in Java)?
> I think that would be very cool since you could establish security
> -mechanisms on top of that.
 
Yes. Research "capability machines"
"Öö Tiib" <ootiib@hot.ee>: Aug 25 02:09PM -0700

On Tuesday, 25 August 2020 19:38:21 UTC+3, Christian Hanné wrote:
> package in Java)?
> I think that would be very cool since you could establish security
> -mechanisms on top of that.
 
That protection (at least in C++) is compile time phenomena.
It is not meant to be for security. As it is compile time only
there are no traces whatsoever of it in generated machine
code.
 
Protection is useful only for programmers (and teams) who want
to avoid accidentally preventing maintainability of class or
even breaking invariant of object instances by access that
bypasses encapsulation.
 
For programmers who wants to bypass encapsulation levels
occasionally (for example for automatically debugging or
unit-testing something) there are ways to do it with totally
well-defined code in C++.
 
For programmers who do not care about encapsulation at all
there is possibility to code everything as public.
 
For programmers who want some kind of actual security there
are thick books and entire newsgroups dedicated to that topic
alone.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Aug 25 05:11PM -0400

On 8/25/20 3:05 PM, Melzzzzz wrote:
>> I think that would be very cool since you could establish security
>> -mechanisms on top of that.
 
> OOP is out of fashion...
 
OOP still has its place. Especially in business applications in lang-
uages like C#, and even BASIC variants and Visual FoxPro.
 
To the OP, the goal of CPU architecture enhancements, like Jazelle in
ARM, are to enhance compute abilities, not to enforce syntax or data
access protocols. The syntax tests for private, protected, public,
etc., are compile-time considerations which determine whether or not
a particular data access is legal via syntax constraints, not hardware
constraints. If you dip down into low-level debugging, you can figure
out a way to access almost anything you want. It's just that the lang-
uage itself won't do that for you via its syntax.
 
Compilers do their job. Hardware does its job. The two are closely
coupled in many ways, but they are also quite disparate and un-coupled
in others.
 
https://en.wikipedia.org/wiki/Jazelle
 
--
Rick C. Hodgin
Mike Copeland <mrc2323@cox.net>: Aug 25 11:41AM -0700

In article <ri2s3o$ssh$1@dont-email.me>, eesnimi@osa.pri.ee says...
 
> This is much more concise and actually strips all leading whitespace,
> not just spaces:
 
> line.erase(0, line.find_first_not_of(" \t\r\n"));
 
Actually, I wound up doing this:
 
auto iter = str.begin();
while(isspace(*iter)) iter++; // skip over leading whitespace
auto ct = (iter-str.begin());
if(ct > 0) str.erase(0, ct); // erase leading whitespace
 
which seems to work. Any problems with it?
 
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Paavo Helde <eesnimi@osa.pri.ee>: Aug 25 11:33PM +0300

25.08.2020 21:41 Mike Copeland kirjutas:
> auto ct = (iter-str.begin());
> if(ct > 0) str.erase(0, ct); // erase leading whitespace
 
> which seems to work. Any problems with it?
 
Yes, it contains a buffer overrun bug if the whole string is whitespace.
 
Otherwise, it's about the same as my one-liner, except that it trims
also \v and \f, and potentially other characters - isspace() is
locale-dependent and so you never know what it might exactly do on a
customer computer.
"Öö Tiib" <ootiib@hot.ee>: Aug 25 09:29AM -0700


> Very pretty. Here's an arcade game that did something similar in 1983 using
> a 1.5Mhz 6809 CPU:
 
> https://en.wikipedia.org/wiki/Star_Wars_(1983_video_game)
 
Yes, the math hasn't changed but the performance. Few lines on 320 x 200
pixels and 16 colors screen 6 frames per second. You now get 100
times more lines on 6 x 6 times bigger screen that are 8 times more
colorful at 10 times faster rate. So 100 * 6 * 6 * 8 * 10 ... 288 000
times more processing needed. But as in everything there are GPUs that
WebGL of Chris can just run in browser window on one of screens attached
to my laptop and it does not affect productivity of anything in any
manner.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: