Specifying Languages

Specifying languages to build your apps in AI

How to choose a language?

There are a number of reasons of to use one programming language over another.

  1. Cost: Some programming languages are free to use, while others require licensing fees or paid support. Depending on the organization's budget, they may choose a language that is more cost-effective for their needs.

  2. Resource expertise: If an organization already has a team of developers who are proficient in a particular programming language, they may choose to use that language for new projects to minimize the need for training and to leverage the team's expertise.

  3. Performance: Some programming languages are better suited for specific tasks or applications than others. For example, C++ is often used for system-level programming and high-performance applications, while Python is popular for data science and machine learning.

  4. Security: Some programming languages have more built-in security features and libraries than others. For example, Rust is designed to prevent memory errors and is often used for systems programming where security is a critical concern.

  5. Compatibility: Some programming languages are more compatible with specific platforms or operating systems than others. For example, Java is known for its cross-platform compatibility, making it a popular choice for developing mobile and web applications.

In our bicycle rental application, we specified the use of Javascript as the primary language, React as the core framework, Next.js as a specific front-end framework on top of React, and Chakra UI as an element library for styling elements like buttons, forms, and sections. This decision was made due to my familiarity with the language, frameworks, and libraries in addition to a large support community.

Language Specfication

After considering the above reasons of choosing one application over another and you have made a selection of which language you would like to proceed with, simply add it to the specifier of your prompt.

For example:

chatgpt-3.5: 
create a filter function to only show items where the type attribute equals "Mountain Bike" in javascript 

"in javascript" is the specifier in the example above.

Version Specification

To specify a language in a LLM, we should remember to specify a version or indicate the latest version in the prompt and keep in mind that the latest in the model may not be the latest version published.

It is always recommended to read the latest documentation and release notes for a language when leveraging generative AI.

For well-established frameworks, breaking changes are not as frequent as newer frameworks that are going through rapid change. Meaning that even if the model is not running off the latest version, the code may still be the most optimal and syntactically correct implementation.

Let's use the difference between Javascript ES5 and ES6 for example.

Example of Differences in Language Versioning

Imports are a feature in JavaScript that allow developers to share and use code from other JavaScript files. The syntax and mechanism for imports differ between ES5 and ES6.

In ES5, developers commonly used script loading to include external JavaScript files in a web page. This technique required creating a new <script> tag in the HTML file and specifying the src attribute to point to the external JavaScript file. The code in the external file would then be executed in the context of the web page.

In ES6, a new syntax for importing and exporting code was introduced, along with a module system that allows developers to define and import modules that encapsulate code and data. The import statement is used to import functions or variables from another module. The new module system allows for static analysis of dependencies, which can result in faster and more efficient code execution.

Here's an example of an import in ES5 and ES6:

In ES5:

<!-- index.html -->

<script src="path/to/external/file.js"></script>
// path/to/external/file.js

function add(a, b) {
  return a + b;
}
// main.js

var result = add(2, 3);
console.log(result); // Output: 5

In ES6:

// module.js

export function add(a, b) {
  return a + b;
}
// main.js

import { add } from './module.js';

var result = add(2, 3);
console.log(result); // Output: 5

In the ES6 example, the export statement is used to export the add function from the module.js file. In the main.js file, the import statement is used to import the add function and make it available for use. This syntax is more concise and allows for better management of dependencies between different JavaScript files.

Last updated