[ home / bans / all ] [ qa / jp ] [ spg ] [ f / ec ] [ b / poll ] [ tv / bann ] [ toggle-new / tab ]

/qa/ - Questions and Answers

Questions and Answers about QA

New Reply

Options
Comment
File
Whitelist Token
Spoiler
Password (For file deletion.)
Markup tags exist for bold, itallics, header, spoiler etc. as listed in " [options] > View Formatting "


[Return] [Bottom] [Catalog]

File:1be1e0452584b0bf6b17e80050….jpg (223.18 KB,1002x1399)

 No.110772

So I was trying to write an IRC bot and while I started off in python I realized at some point maybe I might need to do stuff in javascript as well. It got me wondering if you can just have a bot that's in python that just connects and calls upon javascript programs to do stuff. My first assumption is no since most programs I've seen online seem to be entirely written in one language or another. Since if this was the case then you'd have people mixing and matching languages to do individual tasks ideally because I see a bunch of discussion around languages with people praising something for how well it can do a specific task. If this doesn't exist already, how come?

 No.110778

when you run code in python or javascript it interprets the text that's been sent into it's interpreter. If you had python code that runs in the node runtime, then it would just be javascript code that looks funny. Also language specifications are a thing, so you're not allowed to add things to the language unless the people maintaining it approve. Sure you could, but the maintainers maintain.

There's also things like how python is whitespace sensitive while in javascript you can write it however you want.

Then on the more technical level, python is just calling a bunch of C libraries that it can execute while the node runtime is executing instructions written in javascript for the node runtime. They're not really intercompatible.

So that's to say, you can't really do anything easy to modify javascript, but you can write your own C++ python extensions because python is just an abstraction over C.

 No.110779

PHP, python, lua, lisp. That school of languages are built around providing abstractions for C.
Things like Rust, Go, C++ are turned into machine code by the language creator's compilation tools.
Then some exceptions such as Java and JavaScript exist. They don't really fit into a clear category. Also JIT compilation can make interpretted languages into compiled languages.

So it just doesn't make sense to have programs mix with one another. The best you can do is write custom C like DLL files for them to call or modify the runtime environment to have a function you want and write that in the interprettor's own language

 No.110780

>>110779
Lisp predates C by a good bit actually.

 No.110781

I haven't used it, but I found this after a quick search:
https://github.com/extremeheat/JSPyBridge

 No.110786

>>110780
thought lisp was an interpretted language? So the interpretter is written in assembly?

 No.110789

>>110772
what are you trying to do in javascript that you can't do in python? I'm sure there's some python irc module that lets you just connects to irc with a couple python functions

 No.110790

File:eea4abb029e6d4b02ab6c41d61….jpg (62.78 KB,1019x578)

>>110789
Mostly with javascript I'm trying to utilize the javascript of an SD server to send in generation requests, and my IRC bot is python so I'm a bit confused.

 No.110791

he's confused because I told him that he shouldn't be doing this in python

 No.110800

in my opinion, if someone is in a situation where, god forbid, they want to learn how to code, then it's much easier and valuable for someone who uses a website to learn Javascript and ignore people saying "learn C++ to be a real dev" or "python is easy" or "you'll pick up good fundamentals with Java".
Screw it learn Javascript and understand how functional programming and callbacks work. Understand what it truely means when someone says JS is callback hell

 No.110801

If it gets too clunky you use TypeScript. Then you learn webpack. Before you know it you're learning a frontend framework. Much better than if you are writting dumb Python scripts that get you nowhere fast.
and I'm not really sure what goes into using AI models with NodeJS, but I'm sure someone's done it. So there.
https://github.com/nerdenough/node-sd-webui

 No.110803

https://www.w3schools.com/ai/ai_javascript.asp

This is pretty complex stuff, but there's not a lot of prewritten stuff for AI outside of Python.

 No.110804

>>110790
My gut tells me you're better off doing whatever it is in one language.
Why do you're generation requests need to be in javascript? Why does you're irc bot need to be in python?
I think you'll be better off and learn more just rewriting one or the other in the other language. Though in my personal preference it will be easier to do it all in javascript because you don't have to fiddle around with async functions as much in javascripts.

>>110800
i would think it's easier to learn the fundamentals of object oriented programing with something like java or c++ than with javascript. And then once you understand the general concept of OOP you can move onto python or javascript. Though personally, once you kinda understand java/c++ and know python; javascript is an easy enough jump.
Especially if you're learning programing for a career skill right now, I would rather know python and kinda know javascript than the other way around. Aside from front end webdev stuff, all the "ai" and machine learning stuff is utilizing python modules heavily. And even a lot of backend webdev is using some flavor of python or java.

 No.110806

>>110804
What i meant was that someone who spends a lot of times on websites would get a better tool out of Javascript/Node.
The rest of it doesn't matter much. You'll start writting functional programming concepts more when you write plain javascript.

As a way to make a quick buck. Sure follow the trends. But if you want to pick up a skill that's useful then use JS frameworks and lean heavily on the web servers that come included with popular AI models.

 No.110809

>>110772
surely you can somehow in python call upon any program on your machine like you would in your shell, right? You'd just have to put the work into preparing the input and interpreting the output.

 No.110813

>>110786
Lisp is defined by a standard like C, not a reference implementation like Python, so it depends. But to answer your question, yes, the original Lisp implementation was written in assembly with punch cards.

 No.110836

File:haskell-code-825x450.jpg (57.9 KB,825x450)

Interesting history. Apparently you can make it both compiled and interpreted.

I tried giving Lisp a chance, but it just doesn't appeal. Haskell apparently has something to it hearing Rust people talk about it a lot as the only good other language. If I wanted to go back in time I'd go there.

 No.110887

File:lisp!.jpg (85.03 KB,640x693)

>>110836
>Apparently you can make it both compiled and interpreted.
Being compiled or interpreted is an implementation detail rather than a language characteristic; you could, in theory, implement either a compiler or an interpreter for any language (though an argument could be made certain language features might make it harder to implement good compilers and whatnot), so it doesn't make much sense to say a language is either (and it isn't as clear-cut in any case since you have things like JITs, bytecode interpreters and whatnot). Implementing a small language (something like a Scheme or a Forth) as a side-project might help clearing up some of the confusion; it is also a ton of fun.

Lisp had the original metacircular interpreter (i.e. the Lisp interpreter was written *in Lisp*), which was hand-translated to IBM 704 assembly; but we've also had great compilers for some of it's descendants for decades (see SBCL or Chez Scheme for examples of two pretty good, currently-maintained compilers for Common Lisp and Scheme, respectively). Some implementations only have a compiler, some have both a compiler and an interpreter, some have more than one compiler.

>only good other language.
Haskell has a lot in it for modelling the assumptions of your program at the type level, and letting the compiler prove the correctness of the value level for you, at compile-time; so it'd make sense for Rust people to talk about Haskell like that.

Lisp (now talking about Common Lisp in specific, although the overall philosophy runs, with a varying degree, through the whole family), in the other hand, goes in the opposite direction by giving the programmer as much freedom as possible to do what he feels like doing, including extending the language itself. This, of course, includes the freedom to build yourself into a verifiable, well-typed subset a-la-Haskell (see Coalton; or ACL2 for a theorem prover based on a subset of CL), or to shoot yourself in the foot (note the language doesn't try to make it *easy* to unintentionally do so, in the way that C pointers might, but it certainly won't stop you if you feel like it), or whatever.

A lot of it comes down to opinion, and different people value different things in a language, and so on; certainly you've heard this before.

>If I wanted to go back in time I'd go there.
Haskell is about the same as age as Python, not much older than Java or Ruby; it isn't that old by programming language standards. And it's alive with a dedicated community; GHC is often seem as a breeding ground for experimenting with new language features.

Lisp is almost everyone's granddaddy, but has quite a dedicated community as well, and lots of features you seldom see in newer languages.

>I tried giving Lisp a chance, but it just doesn't appeal.
What did you try? Common Lisp, Scheme, something else? How was your experience? Interactive image-based development, compile-time metaprogramming with macros, a great object system with a metaobject protocol; maybe it's not for everyone, but I certainly think it's a lot of fun.

But Haskell is fun too.

 No.110888

>>110887
Scheme, but someone else's project.
I found that the language itself was preventing me from understanding the project.
Otherwise, I'm just doing normal things picking up ideas and languages from whatever is my focus at the time.
So I'm not really thinking about those concepts when I say I like something or not, it's more about if the syntax/style looks nice( not a fan of the syntax ), accomplishes a goal( webservers are possible but others do it better ) and if I can pick it up quickly ( functional heavy as apposed to procedural/declaritive with no-inheretence OOP ).

 No.110927

anyone know how MongoDB's (or other document DBs) index types compare with MySQL or other relational DBs

 No.118022

File:5790736_p0.png (79.42 KB,480x320)

At my j_b there are C++ <-> C# interactions done via SWIG, C++ <-> JS interactions done via V8, and C# <-> Ruby interactions done by leaving big JSON files at known locations in the filesystem and running a Ruby interpreter as a new process (which is the sort of thing that could be any language <-> any language). Python is used as well. SWIG and V8 are things the whole dev team dreads to touch because it's mostly the b_ssman who knows the intricacies of that stuff.
I joke about using Rust instead of writing any new C++ code but the development philosophy is very much "use boring languages"




[Return] [Top] [Catalog] [Post a Reply]
Delete Post [ ]

[ home / bans / all ] [ qa / jp ] [ spg ] [ f / ec ] [ b / poll ] [ tv / bann ] [ toggle-new / tab ]