Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programming languages that don't suck

Name: Anonymous 2009-11-22 15:41

Lisp, Scheme and Haskell are the obvious ones. JavaScript is a nice language. C always has its place. C# might be the jewel of enterprise.

What else is there that /prog/ recommends? I've heard good things about ML. A language that seems interesting from its Wikipedia page is Self, but I'm not too sure about it.

Name: Anonymous 2009-11-23 12:17

>>38
More like what the fuck any language which DOESN'T implement conditionals as expressions

Name: Anonymous 2009-11-23 13:05

>>39
Then show me a GUI application, written in Prolog.

Oh, that's your problem. Sorry, I'm not buying.

Anyway, I'm saying Python is used irresponsibly and that's what is wrong with it (implementation wise.) On the other hand, these other implementations still underperform, especially when it comes to being responsive. Maybe you're too young to think that 100ms is an abhorrent response time.

I don't like the language itself either, but I don't really care to get hung up on it. I might start throwing spurious exceptions. Feel free to claim that it's not the language's fault that so many libraries are written that way, and I will invite you to rewrite them to support your point.

Name: Anonymous 2009-11-23 13:06

>>41
lisp does it quite well

Name: Anonymous 2009-11-23 14:02

[expert]
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

static int ipairsaux (lua_State *L) {
  int i = luaL_checkint(L, 2);
  luaL_checktype(L, 1, LUA_TTABLE);
  if (i == -1) {
    lua_pushinteger(L, 0);
    lua_rawgeti(L, 1, 0);
  } else {
    i++;
    lua_pushinteger(L, i);
    lua_rawgeti(L, 1, i);
  }
  return (lua_isnil(L, -1)) ? 0 : 2;
}

static int zeroindex_ipairs (lua_State *L) {
  luaL_checktype(L, 1, LUA_TTABLE);
  lua_pushvalue(L, lua_upvalueindex(1));
  lua_pushvalue(L, 1);
  lua_pushinteger(L, -1);
  return 3;
}

char* derp = "t = {[0]='a','b','c','d','e','f'}; for k,v in ipairs(t) do print(k,v); end";

int main(int argc, char** argv) {
    lua_State* L = luaL_newstate();
    luaL_openlibs(L);

    lua_pushvalue(L, LUA_GLOBALSINDEX);
    lua_pushcfunction(L, ipairsaux);
    lua_pushcclosure(L, zeroindex_ipairs, 1);
    lua_setfield(L, -2, "ipairs");

    luaL_loadstring(L, derp);
    lua_call(L, 0, 0);

    return 0;
}
[/expert]

Name: Anonymous 2009-11-23 14:20

>>43
Yep. And they don't even need to return the same type, either, so you can actually use conditionals sanely.

>>44
Okay, now make print(({'a','b','c'})[1]) output b instead of c.

Name: Anonymous 2009-11-23 16:43

>>33
Python and Ruby are fucking slow.

It all narrows down to C and Lisp. This is disappointing.

Name: Anonymous 2009-11-23 17:00

I'd like to nominate Caml/ML. It offers the same speed as Haskell thanks to strong typing and easy type inference(unlike Lisp), and allows mutable variables without the pain of dealing with monads.

>>33
Really? I'd much rather use JavaScript or C# in place of fucking Python and Ruby.

I also nominate Objective-C as the worst C-based language.

Name: Anonymous 2009-11-23 17:10

>>47
There's already an objc hating thread.

Javascript still sucks no matter what way you look at it. It's getting faster but not better.

And OCaml is pretty nice. Wish it had a larger community.

Name: Anonymous 2009-11-23 17:14

>>48 i would rather use haskell than ocaml.
Why? Because Haskell has the better type system.

Name: Anonymous 2009-11-23 17:18

>>49
Really? Haskell's type system looks really stupid next to BCPLs

Name: Anonymous 2009-11-23 17:21

>>39
I don't know that there are GUI applications written in pure Prolog, but there are quite a few written in some Prolog dialects like Visual Prolog, which supports OO. SWI Prolog doesn't really support OO, but it does have a GUI library that is at least object based, IIRC, and the interpreter's help viewer is written in it.

Name: Anonymous 2009-11-23 17:23

>>33
and 1-based arrays are worse than if __name__ == "__main__": how (and don't get me started on Ruby)? i didn't particularly imagine lua to be such an object of controversy, but the fact that none of the discussion here has actually concerned the language itself is kind of sad. lua's 1-based arrays are kind of like lisp's parentheses: they scare away idiots but unfortunately attract trolls.

Name: Anonymous 2009-11-23 17:38

I don't see what's so terrible about 1-based arrays. I don't know Lua, but if it's an otherwise nice language I can live with that mistake.

Name: Anonymous 2009-11-23 17:45

Name: Anonymous 2009-11-23 18:15

>>54
That's not *terrible*, though. It's like complaining about a language because they used do...end instead of {...}.

Name: Anonymous 2009-11-23 18:24

>>55
I'm sure he was just being polite and not calling them out for being the gigantic faggots they are, since that would be disrespectful towards that great computer science faggot who killed himself.

Name: Anonymous 2009-11-23 19:27

>>55
It's dumb because everything else that you ever would want to work with already uses zero, so you're stuck dealing with both kinds of behavior and end up having to either document what functions expect a one-based index and what ones expect a zero-based index, or do a bunch of adjustments everywhere to appease some asshole who at one point thought it'd be a great fucking idea to start arrays at one, and go back on it now because that would take admitting that it was a goddamn dumb idea.

>>56
There's a big difference between just being gigantic faggots, and being stupid faggots. Lua's development team is comprised of the latter.

Name: Anonymous 2009-11-23 19:49

>>57
Most of the lua development team realizes that moving to 0-based arrays now would break just about all the current code around today, and probably cause an untold number of headaches for all of their users. It's not because they think they're smarter than Dijkstra.

Name: Ierusalimschy ~ Lua Dev Team 2009-11-23 20:17

>>54-58
Fuck you, I'm smarter than Dijkstra. 1-based arrays are the real deal and one day we'll prove it.

Name: Anonymous 2009-11-23 21:19

>>58
Yeah, because Lua is so concerned about not breaking code. Practically every release screws up something new.

Name: Anonymous 2009-11-23 22:03

>>45
not sure why you would want [1] do b instead of C (indexing backwards??) but in case you meant
b instead of a (0-based indexing):

http://www.mediafire.com/?50yzezje052

diff --git a/src/lvm.c b/src/lvm.c
index ee3256a..06d8b14 100644
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -130,6 +130,35 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
   luaG_runerror(L, "loop in gettable");
 }
 
+void luaV_gettableX (lua_State *L, const TValue *t, TValue *key, StkId val) {
+  int loop;
+  for (loop = 0; loop < MAXTAGLOOP; loop++) {
+    const TValue *tm;
+    if (ttistable(t)) {  /* `t' is a table? */
+      Table *h = hvalue(t);
+      const TValue *res;
+      if (ttype(key) == LUA_TNUMBER) {
+          res = luaH_getnum(h, nvalue(key)+1);
+      } else {
+          res = luaH_get(h, key); /* do a primitive get */
+      }
+      if (!ttisnil(res) ||  /* result is no nil? */
+          (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
+        setobj2s(L, val, res);
+        return;
+      }
+      /* else will try the tag method */
+    }
+    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
+      luaG_typeerror(L, t, "index");
+    if (ttisfunction(tm)) {
+      callTMres(L, val, tm, t, key);
+      return;
+    }
+    t = tm;  /* else repeat with `tm' */
+  }
+  luaG_runerror(L, "loop in gettable");
+}
 
 void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
   int loop;
@@ -434,7 +463,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
         continue;
       }
       case OP_GETTABLE: {
-        Protect(luaV_gettable(L, RB(i), RKC(i), ra));
+        Protect(luaV_gettableX(L, RB(i), RKC(i), ra));
         continue;
       }
       case OP_SETGLOBAL: {
diff --git a/src/lvm.h b/src/lvm.h
index bfe4f56..268180f 100644
--- a/src/lvm.h
+++ b/src/lvm.h
@@ -28,6 +28,8 @@ LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
 LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
 LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
                                             StkId val);
+LUAI_FUNC void luaV_gettableX (lua_State *L, const TValue *t, TValue *key,
+                                            StkId val);
 LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
                                             StkId val);
 LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);

Name: 2025-12-31 9:57

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00

Name: 1970-01-01 0:00


Newer Posts