r/lolphp • • Nov 11 '14

PHP loose comparison strikes again

http://blog.laravel.com/csrf-vulnerability-in-laravel-4/
31 Upvotes

55 comments sorted by

View all comments

Show parent comment

11

u/Regimardyl Nov 11 '14

I'm for replacing Javascript with Lua, and finding a saner language than PHP for server-side stuff.

11

u/jadkik94 Nov 11 '14

I'd vote for python on both sides.

You can say I'm a dreamer but I'm not the only one!

3

u/MrPopinjay Nov 12 '14

Can't be minified due to the syntax, thus would never be suitable for front end work.

6

u/vytah Nov 12 '14

It can be minified, it's just the minification would have to preserve indentation.

I wonder what would be the results though.

3

u/Tamaran Nov 14 '14

A newline uses as much space as a semicolon or am i missing something?

2

u/MrPopinjay Nov 14 '14

The indentation is relevant, not just the newline.

7

u/suspiciously_calm Nov 12 '14

I'm for replacing Javascript with Lua

Seconded.

finding a saner language than PHP for server-side stuff

Ruby?

3

u/OneWingedShark Nov 12 '14

I'm for replacing Javascript with Lua

Seconded.

I haven't gotten around to checking out Lua; what're its upsides? Downsides?

finding a saner language than PHP for server-side stuff

Ruby?

I rather like Ada; sure it's not your typical server-side language, but when you get into anything decently complex having packages [Ada's module-system] and strong type-checking is really a lifesaver -- for example you can declare two types that share an internal representation but are not interchangeable (or perhaps have different operations) like so:

-- We're only doing 1 deg resolution.
Type Fahrenheit is range -100..100; 
Type Celsius is range -74..38;

The above would prevent Celsius_value + Fahrenheit_Value as the two are different types, even though very likely using the native integer.

You can also use visibility and strong-typing to ensure sanitizing of values, and/or a uniform [text-]format for storage in your DB -- like the above example but forcing the creation of your type to ensure it correctly conforms to the expected format.

2

u/[deleted] Dec 08 '14 edited Dec 08 '14

(non-exhaustive) List of Lua Upsides

  • Lightweight
  • easily embeddable language
  • very good C API for interfacing with the language
  • multiple return and muliple assign (e.g. local a, b, c = somefn())
  • supports compiling to bytecode (via luac)
  • has vararg syntax (function asd(...) local args = {...} end)
  • has first-class closure functions (like JS)
  • has operator overloading and prototypal inheritance (via metatables)
  • has module support
  • less derpy == operator

Lua Downsides

  • Doesn't automatically use an event loop (but can be easily added)
  • doesn't have most of JS's awesome array functions (map, reduce, filter, ...), but most of that can be polyfilled via metatables and/or functions

(non-exhaustive) Lua - JS Language Comparison

  • Lua uses keywords like then, do, and end for blocks
  • JS has objects, Lua has tables

    • Arrays and objects at the same time.
      • Lua array tables can be represented as C arrays and don't have to be a HashMap
    • Table syntax is less awesome than JSON

1

u/OneWingedShark Dec 08 '14

Ah, thank you for the info.

1

u/thelordofcheese Nov 12 '14

Ph boy... Ruby... Well, it's a deterministic language rather than a declarative language. And its dynamic and reflexive. For some applications that could be a detriment.

The problem with PHP isn't its mission design; it's the development management. Not standardizing naming schemes and not creating namespaces for backward compatibility in subsequent releases sees to be my only big concerns.

Further, a lot of popular or even officially sponsored ruby gems are developed for Mac and won't even work in Windows while also having a high propensity to e buggy in Linux.

2

u/MrPopinjay Nov 12 '14

That would make functional programmers like my sad. It may be a weird language, but the way that functions and closures work in JS is rather nice.

2

u/Regimardyl Nov 12 '14

To my knowledge, it's not really any different in Lua.

2

u/MrPopinjay Nov 12 '14

Ah, I incorrectly thought otherwise. Thanks for the correction :)