R
R
Rrooom2014-09-12 11:21:13
Programming
Rrooom, 2014-09-12 11:21:13

Are there analogues of coffescripta for php?

PHP itself is rather poor after the beauty and elegance of the code in go, pythone, the same coffescripte. But it's such a shame that it remains a favorite in the custom web development arena. Incl. due to the high prevalence of hosting for it.
A quick googling told me snow_php, phpreboot, but they smell like unborn carrion. I just do not follow the development of php, maybe there is an outlet for web developers?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
R
RedHairOnMyHead, 2016-08-29
@DmitryProsh

Bitwise operations operate on integer type variables.
While Boolean variables compare two variables in their entirety, bitwise variables compare bits.
For example: a = 11 (which is 1011 in binary), and b = 15 (which is 1111). Then a & b will return 11 (1011) (because 1 and 1 = 1, 1 and 0 = 0, 1 and 1 = 1, 1 and 1 = 1). But if a | b will then return 15 (1111) (1 or 1 = 1, 1 or 0 = 1, 1 or 1 = 1, 1 or 1 = 1).
Here everything is very well shown in the pictures.

V
Vladimir Martyanov, 2016-08-29
@vilgeforce

& is a bitwise operation and works on integers, not bools as you decided.
&& is a logical operation and works with bool.
Similarly with | and ||. Next - Google for the words "% LANGNAME% operators"

R
Rou1997, 2016-08-29
@Rou1997

The first always checks both conditions for truth, the second can only check the first, for && it is enough that the first is false so as not to check the second, for || - the truth of the first, therefore the second ones are slightly more optimal for the speed of the conditions ( if).

A
abcd0x00, 2016-08-30
@abcd0x00

Operations && || ! :
are used to test the truth of their operands.
Operations & | ^ ~ << >> :
used to manipulate bits in their operands.
If you have flag1, flag2, flag3 variables, you can test them to be true:

if ((flag1 && flag2) || !flag3) {
    something;
}

And if you have a states variable, you can check some specific bits in it:
if (states & (0x1 | 0x4)) {
    something;
}

0x1 - bitwise looks like
00000000 00000000 00000000 00000001
0x4 - looks like
bitwise 00000000 00000000 00000000 00000100
0x1 | 0x4 - in the bit view Looks like
00000000 00000000 00000000 00000101
Example1:
If states equals 0x123 - In the bit view it looks like 00000000 00000000
00000001 0000001
States & (0x1 | 0x4) expression - in the bit view will look like
00000000 000000 000000 000000
00000000 00000101
=
00000000 00000000 00000000 00000001
It turned out that the whole expression is equal to 0x1 or just 1.
if (0x1) {
    something;
}

Example2:
If states are 0x122 - In the bit view, it looks like
00000000 00000000 00000001 0000000 0x4
expression (0x1 | 0x4) - in the bit view will look like
00000000 000000 000000 000000 000000 000000 000000 000000 000000 = 00000000
000000.00 000000 000000 00000000 000000 expression is 0x0 or just 0.
if (0x0) {
    something;
}

L
LyoneNET, 2020-11-16
@LioneNET

Everything is quite simple. Basically, this can be easily understood if you use method calls in javascript.
For example:

function a(variant){
    console.log("run a");
    return variant;
}

function b(variant){
    console.log("run b");
    return variant;
}

a(false) & b(false); //произведет вызов обеих функций, даже если первый метод вернет false
a(true) | b(true); //Аналогично первому вызовет оба метода даже если первый вернет true

a(true) || b(true); //второй метод не будет вызван, т.к первый уже вернул true
a(false) && b(true);//второй метод не будет вызван, т.к первый вернул false

M
Maxim Grechushnikov, 2014-09-12
@maxyc_webber

why the heck write in 1 language to compile in another so that the third one compiles and works.

S
Sergey, 2014-09-12
Protko @Fesor

There are projects like snowscript , but for me it's childish fun. IMHO I don't see any reason why PHP needs a preprocessor. What are you going to cut? Sugar over classes is not needed (in js it is still needed and will appear in ES6), it is possible to shorten the declaration of functions / methods, the ability to write getters / setters a la c #. But apparently no one needs it yet, since IDEs generate the whole thing for you if you know how to use them.
Again, if you don't like the PHP syntax, look into Ruby. Or implement your own preprocessor.
There is also:
mammouth.wamalaka.com
And do you know what will be the disadvantage of such solutions? No IDE knows the syntax of these languages.

K
Kir, 2014-09-12
@angry_bender

It probably looks funny or like trolling, but I'm serious. Maybe try Ruby?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question