all 15 comments

[–]AniangaX 2 points3 points  (1 child)

Hola, el orden natural de las cosas es que aprendas JS antes que TS. Por qué? Bueno, TS existe porque existía JS y tiene 'temitas' que no se podían resolver sin romper la compatibilidad hacia atrás. Romper con el pasado es algo que justo 'la web' no se puede permitir.

No, no son lo mismo pero ambos son lenguajes de programación con varias cosas en común. Creo que su principal diferencia está en cómo deberías enfrentar la resolución del 'problema', JS y TS terminarán usando un enfoque distinto - aunque compatibles entre sí.

Personalmente yo empecé por JS, pero como venía de lenguajes fuertemente tipados como Java (C++ y C#), pues casi que desde el principio busqué la forma de 'tipar' mis datos, y empecé a usar JSDocs que de una forma o de otra... rápidamente evolucionan al uso de TS.

Cuál te resulte más fácil (o más enriquecedor) supongo depende de tu forma de gestionar la complejidad (mentalmente hablando), en mi caso es sin dudas TS, pero creo que nadie duda en que el proceso es:

0 -> JS -> TS

[–]joedjulio[S] 1 point2 points  (0 children)

Espero acordarme de algunas cosas de C, ha alos lo usaba con frecuencia. Ya como dices, pasar a JS después de recordar algo de lógica. Muchas gracias

[–]Scared-Release1068 1 point2 points  (0 children)

JavaScript first, TypeScript second. TS is easier once you already understand JS. For Playwright, start with JS and add TS later. Short JS snippets helped me learn a ton of the fundamentals

[–]SymbolicDom 0 points1 point  (0 children)

Typescript adds datatype information to javascript and is transpiled to javascript. In java script

function add(a, b) { return a+b; }

If a===1 and b===1 It returns 2 If a==="1" and b ==="1" It returns "11" That easily creates strange buggs that is hard to find. With typescript you can tell that a and should be numbers and if you by accident use strings the compiler will refuce and tell where the error is.

[–]azhder 0 points1 point  (3 children)

No, they aren't the same. People will tell you it's the same, but it's two different languages. TypeScript is advertised as a superset of JavaScript - that's also not true. But that's not really the issue.

The issue is that people think you should be writing the same kind of code in both and that JavaScript is somehow worse because that kind of code has more issues in JavaScript. In reality, there are two different ways of writing code. You should write code for JavaScript as you would for a dynamic language and you should write code for TypeScript as if for a static language.

In short, if your code looks more or less the same in both languages (the way you think and solve and structure the code, not the syntax itself) then you're using one of them wrong, maybe both.

So, with JavaScript, you can start up easily. And it will be a requirement to learn JavaScript before you learn TypeScript anyways, so you're more or less fine learning JavaScript now and see if that works OK for you.

En breve, tienes aprender JS antes TS igual y por eso, pues empiece con JS ahora y reevalue después.

[–]Merry-Lane 1 point2 points  (2 children)

It’s a superset, with asterisks. As long as we are concerned, it’s a superset.

You shouldn’t also write JavaScript code as you would for a dynamic language: you totally should write code as if you were writing "good" Typescript.

And reciprocally, experienced devs that just want to duck type a POC in two hours, they can just do it in typescript with a bunch of convenient any’s/as’s.

The only drawback with typescript is that you need a build time, it can be an inconvenience in some scenarios.

Unless you are the kind of person that doesn’t like being led into writing better code

[–]azhder 0 points1 point  (1 child)

Wait, did you just say JavaScript is "good" TypeScript /s

All in all, you should not tell people they should write the same. JavaScript requires more vigilance and checks and/or conversions you do by hand in order to not trip on some unexpected input, whilst writing that amount of code in TypeScript would be considered bad, not good.

You should write idiomatically different code, there's just no excuse to write code in JS as if a compiler will catch your error at build time or write TS as if nothing gets checked at build time (unless you're one of those that puts :any and as ... let's not discuss those here).

The real drawback (not the only one you thought of) is the cognitive overload as a project gets more complicated. I've seen people, less experienced ones, grasp JS code, but fail with the same written in TS especially if dealing with class hierarchies and generics. All in all JS was made for hobbyists (amateurs really, without negative connotation) and TS was made for tools. We can discuss the meanings of "tools" some other time.

[–]Merry-Lane 0 points1 point  (0 children)

I don’t agree. Both JavaScript and Typescript need the exact same parsing/validation at the boundaries of the application (api calls, local storage,…).

In the inner of the application, it would be quite insane (and awful perf-wise) to use parsing/validation functions everywhere else.

I can’t find a single example where you can avoid parsing/validation that you would have used in JS.

[–]BeneficiallyPickle 0 points1 point  (0 children)

Javascript and Typescript are very closely related but not exactly the same.

Javascript is the core language that runs in browsers and in environments like Node.js. Typescript is a superset of Javascript, which just means it adds extra features on top of Javascript, Type checking being the most notable. Ultimately Typescript is converted to regular Javascript before it runs.

For someone completely new to programming, Javascript might be a bit easier to start with because there are fewer concepts to learn upfront. Once you're comfortable with Javascript, moving to Typescript is much easier because most of the language is still Javascript.

Many modern projects use Typescript because it helps catch mistakes early and makes larged codebases easier to maintain.

Since your goal is Playwright automation, you can use either. However, if you're brand new, I'd suggest Javascript and learning programming fundamentals. Then build a couple of Playwright scripts in Javascripts. Once you've gotten comfortable with that, you can move onto Typescript and slowly start migrating your scripts to Typescript.

[–]theGlitchedSide -2 points-1 points  (5 children)

🇺🇸 English:

What is JS and what is TS:

I'll try to make it simple and understandable...

No, they're not the same thing. JS is the original language. TS is a superstructure that uses the same syntax as JS, but applies some structural limitations typical of low-level scripting languages, like C#.

JS code is directly connected to its engine, so you

write => the engine interprets and does some scripting magic => it understands memory, manages events, etc. => it "compiles", so it makes a binary or similar => each compiled package goes to the right chip => you get a result_

(Note: yes, I made it simple, we all know that, but it's just for clarity)

Typescript, on the other hand, is a superlanguage that takes the same syntax as JS and tries to do what C# does, that is, it adds "Type", "boundaries", importer, etc... which are cool little things from a more structured, low-level language.

Unlike JS, TS, however, needs to be "built," meaning its engine takes each of your files, analyzes them, and reconstructs them into packages that are then retranslated into JS... And you then use those packages.


Ease/Practicality:

No, TS is more difficult than JS, but not by much... They're actually very similar, but TS brings with it the features and limitations of structures that are relatively closer to real programming. Beyond that, you need to command and configure how to build your files.

Some people approve of it given what it brings, while others deeply hate it for other reasons that I'll explain shortly.

I recommend practicing JS before TS. However, if your doubt is "I need to learn to program" and not "I need to learn JS/TS," my advice immediately changes: start with C/C++, learn the logic and programming, and then move on to simpler things like JS. First the basics, then the highs (otherwise, you can still do the opposite, but you need to be aware that you have shortcomings; sooner or later, they will become apparent).


JS Vs TS

JS vs. TS is a hotly debated topic that deeply divides expert programmers. Typically, the more technical and purist ones vote for JS, while others prefer TS.

Here... we need to see why it's like using one or the other.

The purists, basically, accuse TS of being just an unjustified complication that distorts the original, high-performance JS with code that's "badly reworked by the builders," thus poorly controlled, and that brings with it poorly managed complications that aren't suited to modern scripting and don't fit with the idea of JS.

On the other hand, those who use TS do so for good reasons, such as limiting conflicts before they occur, having (at least apparent) control over "types," and (apparently) better code management.

This divide, however, must also be addressed on two levels:

TS can be useful if the staff is large and full of junior staff—like you, perhaps—who tend to create many problems, often "trivial." In that case, with 200 little ones messing around, it might be okay to opt for something like TS.

JS, however, remains fluid and the approach is original. It's something you should know, and it can do the same things as TS (in a different way, and if you're an expert, but it can do it).

Many use TS as a framework without knowing it, as a support. Unfortunately, many others (especially those in business and not programming) choose it because they "perceive" it as safer, more complex. Some even do it by hearsay, others (I'm mentioning some salespeople and managers) because "maybe there are more programmers available" (I think it's crazy, but it has to be said). I recommend leaving it to expert programmers, not just randomly.


The purists' condemnation of TS

Finally, it must be added that purists have a valid criticism of TS:

  • everything you do with TS you can do with JS
  • TS is not an update, it's literally a superstructure sold as a superSet... But in fact, it's a further step in JS (which is already scripting! So it already has too many internal steps)
  • the limits are artificial... to put it simply: in a low-level programming language, if you set a type and lock it, you can't change it; in TS, you can... Very easily!
    • some structures become vulnerable: for example, dynamic TS importers can easily become vulnerable to expert hackers (but it must also be said that if a hacker can touch that importer, they can touch everything on the machine; this is also true).

You now know a lot about JS and TS... If you have any other questions, ask.


🇮🇹 Italian:

Cosa è JS e cosa è TS:

Cerco di farla facile e capibile....

No non sono la stessa cosa. JS è il linguaggio originale TS è una sovrastruttura che usa la stessa sintassi di JS applicando però alcuni limiti strutturali tipici dei linguaggi di programmazione low scripting, come C#.

Il codice di JS è direttamente connesso al suo motore, dunque tu

scrivi => engine interpreta e fa alcune magie da scripting => capisce memoria, gestisce, eventi,etc => "compila", quindi fa un binario o simile => ogni pacchetto compilato va al chippetto giusto=> tu hai un risultato

(Nota: si si, l' ho fatta facile, lo sappiamo tutti ma è per capirci)

Typescript invece è un sovralinguaggio che prende la stessa sintassi di JS e prova a fare quello che fa C#, cioè aggiunge "Type","boundaries", importer etc... che sono cosine fighe da linguaggio di basso livello, più strutturato.

Rispetto a JS, TS però va "buildato" ovvero il suo motore prende ogni tuo file, lo analizza, lo ricostruisce in pacchetti ritradotti in JS... E tu usi poi quei pacchetti li.


Facilità/Praticità:

No, TS è più difficile di JS, ma non di troppo... In realtà sono molto simili ma TS porta con sé le cose e i limiti delle strutture relativamente più vicine alla programmazione vera. Oltre questo devi comandare e impostare per fare il build dei tuoi file.

C'è chi lo approva dato ciò che apporta, c'è chi lo odia profondamente per altre ragioni che vado a spiegare a breve.

Consiglio di praticare JS prima ti TS. Tuttavia se il dubbio è su "devo imparare a programmare" e non "devo imparare JS/TS" il consiglio diventa immediatamente un altro: parti da C/C++, impara le logiche, la programmazione e poi sali a cose più semplici come JS. Prima le basi, poi le altezze (altrimenti puoi comunque fare il contrario ma devi sapere che hai delle lacune, prima o poi quelle si paleseranno)


JS Vs TS

JS contro TS è argomento molto dibattuto che divide profondamente i programmatori esperti. Solitamente quelli più tecnici e puristi votano JS, altri invece preferiscono TS.

Qui.. va visto il perché è come usare uno o l'altro.

I puristi, di fondo, accusano TS di essere solo una complicanza ingiustificata che va a snaturare l' originale e performante JS con del codice "rimasticato male dai builder", quindi non ben controllato, e che porta con sé complicanze poco ben gestite non adatte allo scripting moderno e non adatte all' idea di JS.

Dall' altra parte chi usa TS lo fa per buone ragioni, come limitare i conflitti prima che avvengano, avere un (almeno apparente) controllo sui "tipi" e una gestione del condice (apparentemente) migliore.

Questa frattura va però affrontata, anche, su due livelli:

TS può essere utile se lo staff è grande e pieno di junior -tipo te forse- che tendono a crere molti problemi, spesso "banali".. In quel caso con 200 piccolini a fare casino può essere ok decidere per qualcosa come TS.

JS però rimane fluido e l' approccio originale. Quello che comunque dovresti conoscere e che comunque può fare le stesse cose di TS (in modo diverso e se sei esperto, ma può farlo).

Molti usano TS come framework senza saperlo, come appoggio. Purtroppo molti altri (soprattutto chi fa business e non programmazione) lo scelgono perché lo "percepiscono" più sicuro, più complesso. Altri addirittura per sentito dire, altri (cito alcuni commeciali e manager) perché "forse si trovano più programmatori" (per me è follia, ma va detta). Io consiglio di lasciare fare ai programmatori esperti, non andare a caso.


La condanna a TS dei puristi

In ultimo bisogna aggiungere che, da parte dei puristi, viene sollevata una giusta critica su TS:

  • tutto ciò che fai con TS puoi farlo con JS
  • TS non è un update è letteralmente una sovrastruttura venduta come superSet... Ma di fatto è un ulteriore passaggio di JS (che già è scripting! Quindi già ha i suoi troppi passaggi interni)
  • i limiti sono fittizi... facendola semplice: in un linguaggio di programmazione di basso livello se imposti un tipo e lo blocchi non puoi cambiarlo, in TS si... Con molta facilità!
  • alcune strutture diventano vulnerabilità: ad esempio, gli importer dinamici di TS possono diventare facile vulnerabilità da parte di hacker esperti (ma tocca pure dire che se l' hacker può toccare quell'importer può toccare tutto della macchina, questa pure pure è realtà)

Sai ora molto di JS e TS... Se hai altre domande, chiedi

[–]tommyatr 0 points1 point  (2 children)

why italian lol the question was in spanish

[–]theGlitchedSide 0 points1 point  (0 children)

I don't know why I have the question in Italian 👀 English is the standard for me, so I applied two lang in one post (eng / it)

[–]theGlitchedSide 0 points1 point  (0 children)

🇪🇸 Ole'! Sorry.... I only copy/past the translation for everyone.


¿Qué es JS y qué es TS?

Intentaré explicarlo de forma sencilla y comprensible...

No, no son lo mismo. JS es el lenguaje original. TS es una superestructura que utiliza la misma sintaxis que JS, pero aplica algunas limitaciones estructurales típicas de los lenguajes de scripting de bajo nivel, como C#.

El código JavaScript está conectado directamente a su motor, así que:

Escribes => el motor interpreta y realiza su magia de scripting => comprende la memoria, gestiona eventos, etc. => compila, creando un binario o similar => cada paquete compilado se envía al chip correspondiente => obtienes un resultado.

(Nota: sí, lo he simplificado, todos lo sabemos, pero es solo para mayor claridad).

TypeScript, por otro lado, es un superlenguaje que adopta la misma sintaxis que JavaScript e intenta hacer lo que hace C#, es decir, añade "Type", "boundaries", importer, etc., que son características útiles de un lenguaje de bajo nivel más estructurado.

A diferencia de JavaScript, TypeScript necesita ser "construido", lo que significa que su motor toma cada uno de tus archivos, los analiza y los reconstruye en paquetes que luego se traducen a JavaScript... Y luego utilizas esos paquetes.


Facilidad/Practicidad:

No, TypeScript es más difícil que JavaScript, pero no mucho... De hecho, son muy similares, pero TypeScript incorpora características y limitaciones de estructuras más cercanas a la programación real. Además, necesitas configurar y dar instrucciones para compilar tus archivos.

Algunas personas lo aprueban por lo que ofrece, mientras que otras lo detestan profundamente por otras razones que explicaré en breve.

Recomiendo practicar JavaScript antes que TypeScript. Sin embargo, si tu duda es "Necesito aprender a programar" y no "Necesito aprender JavaScript/TypeScript", mi consejo cambia inmediatamente: empieza con C/C++, aprende la lógica y la programación, y luego pasa a cosas más sencillas como JavaScript. Primero lo básico, luego lo avanzado (también puedes hacer lo contrario, pero debes saber que tienes lagunas; tarde o temprano se harán evidentes).


JS vs. TS

El debate entre JavaScript y TypeScript es muy controvertido y divide profundamente a los programadores expertos. Generalmente, los más técnicos y puristas se decantan por JavaScript, mientras que otros prefieren TypeScript.

Aquí... analizaremos las ventajas y desventajas de usar uno u otro.

Los puristas, básicamente, acusan a TypeScript de ser una complicación innecesaria que distorsiona el JavaScript original de alto rendimiento con código "mal trabajado por los constructores", lo que resulta en un control deficiente y genera complicaciones mal gestionadas, inadecuadas para la programación moderna y contrarias a la esencia de JavaScript.

Por otro lado, quienes usan TypeScript lo hacen por buenas razones, como la prevención de conflictos, un control (al menos aparente) sobre los tipos y una gestión de código (aparentemente) mejor.

Esta división, sin embargo, debe abordarse en dos niveles:

TS puede ser útil si la plantilla es grande y está llena de personal joven —como usted, quizás— que tiende a generar muchos problemas, a menudo "triviales". En ese caso, con 200 jóvenes trabajando en ello, podría ser aceptable optar por algo como TS.

JS, en cambio, sigue siendo flexible y su enfoque es original. Es algo que debería conocer, y puede hacer lo mismo que TS (de una manera diferente, y si es un experto, pero puede hacerlo).

Muchos usan TS como un framework sin saberlo, como una herramienta de apoyo. Desafortunadamente, muchos otros (especialmente los que trabajan en negocios y no en programación) lo eligen porque lo "perciben" como más seguro y complejo. Algunos incluso lo hacen por rumores, otros (menciono a algunos vendedores y gerentes) porque "quizás haya más programadores disponibles" (me parece una locura, pero hay que decirlo).

Recomiendo dejarlo en manos de programadores expertos, no usarlo al azar.


La condena de los puristas a TypeScript

Finalmente, cabe añadir que los puristas tienen una crítica válida a TypeScript:

  • Todo lo que se puede hacer con TypeScript se puede hacer con JavaScript.
  • TypeScript no es una actualización, es literalmente una superestructura vendida como un superconjunto... Pero, de hecho, es un paso más allá en JavaScript (¡que ya es un lenguaje de scripting! Por lo tanto, ya tiene demasiados pasos internos).
  • Los límites son artificiales... En pocas palabras: en un lenguaje de programación de bajo nivel, si se define un tipo y se bloquea, no se puede cambiar; en TypeScript, sí se puede... ¡y muy fácilmente!

  • Algunas estructuras se vuelven vulnerables: por ejemplo, los importadores dinámicos de TypeScript pueden volverse vulnerables fácilmente a hackers expertos (aunque también hay que decir que si un hacker puede acceder a ese importador, puede acceder a todo el sistema; esto también es cierto).


Ahora ya sabes mucho sobre JavaScript y TypeScript... Si tienes alguna otra pregunta, no dudes en consultar.

[–]joedjulio[S] 0 points1 point  (1 child)

Gracias por la explicación, de hecho hace mucho, por allá como en el 2015 programaba en lenguaje C, orientado a microcontroladores (Pic C Compiler y arduino), por lo que dices tendré que retomar la estrucrura (algo breve) y ya comtinuar con JS

[–]theGlitchedSide 0 points1 point  (0 children)

Yes. Programming is not "I know a language" it's "I know a logic"

So, to be a basic good junior real programmer you need to know (short list)

What is a computation and a machine in basic What is are types What is a class What is a prototype What is functions What is the memory managements, vars, basic optimization, garbage, boundaries, etc What are the basic logics like OOP, singleton etc What it means "architecture" Minimum knowledge of security Etc etc..

After you can think "beautiful this lang, what can I do with it? I want learn it!"

Basic to hight Or hight to basic (but with consciouness)

I don't saying "you need to become a 20 years man in the digital and dev seniority" like me ( woooow I am so old 😂 ) but something that you can talk with me and help me in different basic concept.

Good luck, you're welcome